Commit d4341238 authored by Helperhaps's avatar Helperhaps

add group push example

parent f5ff2331
......@@ -10,10 +10,12 @@ from . import device_example
from . import push_example
from . import report_example
from . import schedule_example
from . import group_push_example
__all__ = [
device_example,
push_example,
report_example,
schedule_example
]
\ No newline at end of file
schedule_example,
group_push_example
]
from . import jpush
from jpush import common
group_key = u'xxxxxx'
group_secret = u'xxxxxx'
group = jpush.GroupPush(group_key, group_secret)
group.set_logging("DEBUG")
def all():
push = group.create_push()
push.audience = jpush.all_
push.notification = jpush.notification(alert="!hello python jpush api")
push.platform = jpush.all_
try:
response=push.send()
except common.Unauthorized:
raise common.Unauthorized("Unauthorized")
except common.APIConnectionException:
raise common.APIConnectionException("conn")
except common.JPushFailure:
print ("JPushFailure")
except:
print ("Exception")
......@@ -11,4 +11,4 @@ def receivede():
report.get_received("3289406737")
def users():
report.get_users("DAY","2016-04-10","3")
\ No newline at end of file
report.get_users("DAY","2016-04-10","3")
......@@ -34,4 +34,4 @@ def put_schedule():
trigger=jpush.schedulepayload.trigger("2016-05-17 12:00:00")
schedulepayload=jpush.schedulepayload.schedulepayload("update a new name", True, trigger, push)
schedule.put_schedule(schedulepayload,"17349f00-0852-11e6-91b1-0021f653c902")
\ No newline at end of file
schedule.put_schedule(schedulepayload,"17349f00-0852-11e6-91b1-0021f653c902")
......@@ -16,6 +16,7 @@ logger = logging.getLogger('jpush')
class JPush(object):
def __init__(self, key, secret):
self.key = key
print(key)
self.secret = secret
self.session = requests.Session()
self.session.auth = (key, secret)
......
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