Skip to content

Instantly share code, notes, and snippets.

@TylerMills
Last active December 18, 2015 05:38
Show Gist options
  • Select an option

  • Save TylerMills/a735161d516723954d6d to your computer and use it in GitHub Desktop.

Select an option

Save TylerMills/a735161d516723954d6d to your computer and use it in GitHub Desktop.
Localytics CID Push
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