Last active
December 18, 2015 05:38
-
-
Save TylerMills/a735161d516723954d6d to your computer and use it in GitHub Desktop.
Localytics CID Push
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import requests | |
| import json | |
| APP_KEY = 'APP_KEY_HERE' # settings -> apps in localytics dashboard | |
| API_KEY = 'API_KEY_HERE' # settings -> API keys localytics dashboard | |
| API_SECRET = 'API_SECRET_HERE' # settings -> API keys localytics dashboard | |
| headers = {'content-type': 'application/json'} | |
| endpoint = 'https://messaging.localytics.com/v2/push/' + APP_KEY | |
| user = 'ABC123' # matching customer ID set in app with localytics SDK | |
| message = 'Hi Mom!' # modify to appropriate message | |
| payload = { | |
| "campaign_key": "test_campaign", | |
| "target_type": "customer_id", | |
| "messages": [ | |
| { | |
| "target" : user, | |
| "alert": message | |
| } | |
| ] | |
| } | |
| push = requests.post(endpoint, json.dumps(payload), auth=(API_KEY, API_SECRET), headers=headers) | |
| print(push.status_code) | |
| print(push.text) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment