|
@@ -27,9 +27,16 @@ import time
|
|
class Test(View):
|
|
class Test(View):
|
|
|
|
|
|
def get(self, request, *args, **kwargs):
|
|
def get(self, request, *args, **kwargs):
|
|
|
|
+ return self.do_gcm_push(request)
|
|
|
|
+
|
|
|
|
+ def do_gcm_push(self,request):
|
|
import json
|
|
import json
|
|
import requests
|
|
import requests
|
|
-
|
|
|
|
|
|
+ response = ResponseObject()
|
|
|
|
+ rg_id = request.GET.get('rg_id', '')
|
|
|
|
+ serverKey = request.GET.get('serverKey', '')
|
|
|
|
+ if not rg_id or not serverKey:
|
|
|
|
+ return response.json(444)
|
|
data = {
|
|
data = {
|
|
"key1": "abc",
|
|
"key1": "abc",
|
|
"key2": "def"
|
|
"key2": "def"
|
|
@@ -40,13 +47,10 @@ class Test(View):
|
|
"data": data,
|
|
"data": data,
|
|
"delay_while_idle": False,
|
|
"delay_while_idle": False,
|
|
"time_to_live": 3600,
|
|
"time_to_live": 3600,
|
|
- "registration_ids": [
|
|
|
|
- 'eSooD4fAARg:APA91bEPenBPnSn5aXIQk56QdLOQ1Mu3hevHsekP_0eDpg458y2ZMBP6By2rVsGYIoxZrXxvkkptPKUE9CmUygBxaZXABddUWB9FyLlznRFerC7RG9X5PsEOH58xK9_aTUdkT7p6Ocld']
|
|
|
|
|
|
+ "registration_ids": [rg_id]
|
|
}
|
|
}
|
|
|
|
|
|
url = 'https://android.googleapis.com/gcm/send'
|
|
url = 'https://android.googleapis.com/gcm/send'
|
|
- serverKey = "AAAAb9YP3rk:APA91bHu8u-CTpcd0g6lKPo0WNVqCi8jZub1cPPbSAY9AucT1HxlF65ZDUko9iG8q2ch17bwu9YWHpK1xI1gHSRXCslLvZlXEmHZC0AG3JKg15XuUvlFKACIajUFV-pOeGRT8tM6-31I"
|
|
|
|
-
|
|
|
|
data = json.dumps(json_data).encode('utf-8')
|
|
data = json.dumps(json_data).encode('utf-8')
|
|
headers = {'Content-Type': 'application/json', 'Authorization': 'key=%s' % serverKey}
|
|
headers = {'Content-Type': 'application/json', 'Authorization': 'key=%s' % serverKey}
|
|
req = requests.post(url, data, headers=headers)
|
|
req = requests.post(url, data, headers=headers)
|