chenjunkai 6 жил өмнө
parent
commit
1bf21bf3a6
1 өөрчлөгдсөн 27 нэмэгдсэн , 25 устгасан
  1. 27 25
      Controller/Test.py

+ 27 - 25
Controller/Test.py

@@ -27,32 +27,34 @@ class Test(View):
 
     def get(self, request, *args, **kwargs):
         response = ResponseObject()
+        devToken = request.get('devToken',None)
+        import jpush as jpush
 
-        app_private_key_string = open(BASE_DIR + '/Controller/alipay_private_2048.pem').read()
-        alipay_public_key_string = open(BASE_DIR + '/Controller/alipay_public_2048.pem').read()
-        orderID = int(time.time()) + int(time.time())
-        alipay = AliPay(
-            appid="2016092200569234",
-            app_notify_url=None,  # the default notify path
-            app_private_key_string=app_private_key_string,
-            # alipay public key, do not use your own public key!
-            alipay_public_key_string=alipay_public_key_string,
-            sign_type="RSA2",  # RSA or RSA2
-            debug=False  # False by default
-        )
-        order_string = alipay.api_alipay_trade_wap_pay(
-            out_trade_no=str(orderID),
-            total_amount=0.01,
-            subject="实用性充气式玩具",
-            return_url="http://192.168.136.40:8077/",
-            notify_url="http://test.dvema.com:8077/Test"  # this is optional
-        )
-        print(order_string)
-        from django.http import HttpResponseRedirect
-        # return response.json(0,"https://openapi.alipay.com/gateway.do? + {order_string}".format(order_string=order_string))
-        print(order_string)
-        return HttpResponseRedirect("https://openapi.alipaydev.com/gateway.do?" + order_string)
-        return HttpResponseRedirect("https://openapi.alipay.com/gateway.do?" + order_string)
+        # 此处换成各自的app_key和master_secret
+        app_key = 'b85cd8c899fa549535e61ecc'
+        master_secret = '6ce8d1ce403ae102661ca3b8'
+
+        _jpush = jpush.JPush(app_key, master_secret)
+        _jpush.set_logging("DEBUG")
+        ###########
+        push = _jpush.create_push()
+
+        # push.audience = jpush.all_
+        push.audience = devToken
+        push.platform = jpush.all_
+
+        # ios = jpush.ios(alert="Hello, IOS JPush!", sound="a.caf", extras={'k1': 'v1'})
+        android = jpush.android(alert="Hello, Android msg", priority=1, style=1, alert_type=1, big_text='jjjjjjjjjj',
+                                extras={'k1': 'v1'})
+
+        push.notification = jpush.notification(alert="Hello, JPush!", android=android)
+
+        # pprint (push.payload)
+        push.send()
+
+
+
+        return response.json(0)
 
     def post(self, request, *args, **kwargs):
         response = ResponseObject()