diff --git a/examples/__init__.py b/examples/__init__.py index 46ef33c..f1318b5 100644 --- a/examples/__init__.py +++ b/examples/__init__.py @@ -10,10 +10,12 @@ 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 +] diff --git a/examples/group_push_example.py b/examples/group_push_example.py new file mode 100644 index 0000000..773d63c --- /dev/null +++ b/examples/group_push_example.py @@ -0,0 +1,24 @@ +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") diff --git a/examples/report_example.py b/examples/report_example.py index fbab71d..9b89576 100644 --- a/examples/report_example.py +++ b/examples/report_example.py @@ -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") diff --git a/examples/schedule_example.py b/examples/schedule_example.py index 4feb20c..588d916 100644 --- a/examples/schedule_example.py +++ b/examples/schedule_example.py @@ -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") diff --git a/jpush/core.py b/jpush/core.py index 7b87c25..d19a7a9 100644 --- a/jpush/core.py +++ b/jpush/core.py @@ -16,6 +16,7 @@ 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)