|
@@ -27,6 +27,32 @@ import time
|
|
|
class Test(View):
|
|
|
|
|
|
def get(self, request, *args, **kwargs):
|
|
|
+ import json
|
|
|
+ import requests
|
|
|
+
|
|
|
+ data = {
|
|
|
+ "key1": "abc",
|
|
|
+ "key2": "def"
|
|
|
+ }
|
|
|
+
|
|
|
+ json_data = {
|
|
|
+ "collapse_key": "WhatYouWant",
|
|
|
+ "data": data,
|
|
|
+ "delay_while_idle": False,
|
|
|
+ "time_to_live": 3600,
|
|
|
+ "registration_ids": [
|
|
|
+ 'eSooD4fAARg:APA91bEPenBPnSn5aXIQk56QdLOQ1Mu3hevHsekP_0eDpg458y2ZMBP6By2rVsGYIoxZrXxvkkptPKUE9CmUygBxaZXABddUWB9FyLlznRFerC7RG9X5PsEOH58xK9_aTUdkT7p6Ocld']
|
|
|
+ }
|
|
|
+
|
|
|
+ url = 'https://android.googleapis.com/gcm/send'
|
|
|
+ serverKey = "AAAAb9YP3rk:APA91bHu8u-CTpcd0g6lKPo0WNVqCi8jZub1cPPbSAY9AucT1HxlF65ZDUko9iG8q2ch17bwu9YWHpK1xI1gHSRXCslLvZlXEmHZC0AG3JKg15XuUvlFKACIajUFV-pOeGRT8tM6-31I"
|
|
|
+
|
|
|
+ data = json.dumps(json_data).encode('utf-8')
|
|
|
+ headers = {'Content-Type': 'application/json', 'Authorization': 'key=%s' % serverKey}
|
|
|
+ req = requests.post(url, data, headers=headers)
|
|
|
+ return self.jgPush(request)
|
|
|
+
|
|
|
+ def jgPush(self, request):
|
|
|
response = ResponseObject()
|
|
|
devToken = request.GET.get('devToken', '')
|
|
|
app_key = request.GET.get('app_key', '')
|
|
@@ -47,7 +73,7 @@ class Test(View):
|
|
|
res = push.send()
|
|
|
except Exception as e:
|
|
|
print("Exception")
|
|
|
- return response.json(10,repr(e))
|
|
|
+ return response.json(10, repr(e))
|
|
|
return response.json(0)
|
|
|
|
|
|
def post(self, request, *args, **kwargs):
|