Commit abae8226 authored by hupantingxue's avatar hupantingxue

Validate Push;

parent 31f7ebfb
import jpush as jpush
from conf import app_key, master_secret
_jpush = jpush.JPush(app_key, master_secret)
push = _jpush.create_push()
push.audience = jpush.all_
push.notification = jpush.notification(alert="Hello, world!")
push.platform = jpush.all_
push.send_validate()
......@@ -4,6 +4,7 @@ import logging
BASE_URL = "https://api.jpush.cn/"
PUSH_URL = BASE_URL + 'v3/push'
VALIDATE_PUSH_URL = BASE_URL + 'v3/push/validate'
DEVICE_BASEURL = "https://device.jpush.cn/"
DEVICE_URL = DEVICE_BASEURL + "v3/devices/"
......
......@@ -48,6 +48,22 @@ class Push(object):
print (response.content)
return PushResponse(response)
def send_validate(self):
"""Send the notification to validate.
:returns: :py:class:`PushResponse` object with ``push_ids`` and
other response data.
:raises JPushFailure: Request failed.
:raises Unauthorized: Authentication failed.
"""
body = json.dumps(self.payload)
response = self._jpush._request('POST', body,
common.VALIDATE_PUSH_URL, 'application/json', version=3)
print (response.content)
return PushResponse(response)
class PushResponse(object):
"""Response to a successful push notification send.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment