How to use dingdong Push in ApSpace using Python
ENDPOINT URL: https://api.apiit.edu.my/dingdong/new
At first we need to use the following function to generate service ticket:
def generate_st(service_url): credentials = (USER + ":" + PASSWORD).split(':') resp = requests.post('https://cas.apiit.edu.my' + '/cas/v1/tickets/', data={'username': credentials[0], 'password': credentials[1]}) if resp.status_code == 201: resp = requests.post(resp.headers['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 = requests.post('https://api.apiit.edu.my/dingdong/new', 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.