How to use dingdong Push in ApSpace using Python

You are here:
< Back

At first we need to use the following function to generate service ticket:

def generate_st(service_url):
    credentials = (USER + ":" + PASSWORD).split(':')
    resp ='' + '/cas/v1/tickets/', data={'username': credentials[0], 'password': credentials[1]})
    if resp.status_code == 201:
        resp =['Location'], data={'service': service_url})
    if resp.status_code == 200:
        return resp.text

Following are the parameters need to send to the endpoint:

msg = "Custom message"
payload = {'title': 'Title of the notification', 'msg': msg,
           'to': [{'item': 'receiver_cas_ID', 'type': 'staff/student'}]

headers = {'Authorization': 'Bearer ' + generate_st(service_url)}
r ='', json=payload, headers=headers

You need to have the authorized CAS account to generate the service ticket and to send the notifications.





Did not find what you were looking for? Open a ticket with our Help Centre and we will get back to you resolve your issue.Click Here.
Was this article helpful?
How can we improve this article?
Need help?