Python client for Amazon Device Messaging (ADM).
- pycurl2 - a more modern PyCURL fork
- human_curl - Simple cURL wrapper for Humans
Sample usage
from admclient import ADM, flatten
client = ADM(client_id, client_secret)
# see this http://stackoverflow.com/questions/11378004/with-android-gcm-can-you-use-a-deep-json-data-field
# on why we need to flatten nested JSON structures
payload = flatten({'examplekey': {'key1': 'value1'}})
response = client.send(registration_id, payload)
# Error handling
if 'errors' in response:
for reg_id, reason in response['errors'].items():
if reason is 'InvalidRegistrationId':
# Remove reg_ids from database
pass
if 'canonical' in response:
for reg_id, canonical_id in response['canonical'].items():
# Replace reg_id with canonical_id in your database
pass
pip install https://github.com/Lispython/pycurl/archive/master.zip
pip install https://github.com/Lispython/human_curl/archive/master.zip
pip install https://github.com/bananos/adm-client/archive/master.zip
This work is based on original code from Python-adm.