Commit d4341238 authored by Helperhaps's avatar Helperhaps

add group push example

parent f5ff2331
...@@ -10,10 +10,12 @@ from . import device_example ...@@ -10,10 +10,12 @@ from . import device_example
from . import push_example from . import push_example
from . import report_example from . import report_example
from . import schedule_example from . import schedule_example
from . import group_push_example
__all__ = [ __all__ = [
device_example, device_example,
push_example, push_example,
report_example, report_example,
schedule_example schedule_example,
] group_push_example
\ No newline at end of file ]
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(): ...@@ -11,4 +11,4 @@ def receivede():
report.get_received("3289406737") report.get_received("3289406737")
def users(): def users():
report.get_users("DAY","2016-04-10","3") report.get_users("DAY","2016-04-10","3")
\ No newline at end of file
...@@ -34,4 +34,4 @@ def put_schedule(): ...@@ -34,4 +34,4 @@ def put_schedule():
trigger=jpush.schedulepayload.trigger("2016-05-17 12:00:00") trigger=jpush.schedulepayload.trigger("2016-05-17 12:00:00")
schedulepayload=jpush.schedulepayload.schedulepayload("update a new name", True, trigger, push) schedulepayload=jpush.schedulepayload.schedulepayload("update a new name", True, trigger, push)
schedule.put_schedule(schedulepayload,"17349f00-0852-11e6-91b1-0021f653c902") schedule.put_schedule(schedulepayload,"17349f00-0852-11e6-91b1-0021f653c902")
\ No newline at end of file
...@@ -16,6 +16,7 @@ logger = logging.getLogger('jpush') ...@@ -16,6 +16,7 @@ logger = logging.getLogger('jpush')
class JPush(object): class JPush(object):
def __init__(self, key, secret): def __init__(self, key, secret):
self.key = key self.key = key
print(key)
self.secret = secret self.secret = secret
self.session = requests.Session() self.session = requests.Session()
self.session.auth = (key, secret) 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