Skip to content

Instantly share code, notes, and snippets.

@guilhermecarvalhocarneiro
Created March 11, 2014 19:20
Show Gist options
  • Save guilhermecarvalhocarneiro/9493057 to your computer and use it in GitHub Desktop.
Save guilhermecarvalhocarneiro/9493057 to your computer and use it in GitHub Desktop.
def send_message(self):
json_data ={"collapse_key":"msg","data":{"data":"xyz",},"registration_ids":['APA91bH2DtFn9494z-*****bMP1BPUsVI8ltb395MNp-39k8sp0',],}
url ='https://android.googleapis.com/gcm/send'
myKey ="AIzaSyC********************A7S"
data = json.dumps(json_data)
headers ={'Content-Type':'application/json','Authorization':'key=%s'% myKey}
req = urllib2.Request(url, data, headers)
f = urllib2.urlopen(req)
response = json.loads(f.read())
self.response.out.write(json.dumps(response,sort_keys=True, indent=2))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment