Skip to content

Commit

Permalink
add group push example
Browse files Browse the repository at this point in the history
  • Loading branch information
Helperhaps committed Jul 19, 2017
1 parent f5ff233 commit d434123
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 4 deletions.
6 changes: 4 additions & 2 deletions examples/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
]
schedule_example,
group_push_example
]
24 changes: 24 additions & 0 deletions examples/group_push_example.py
Original file line number Diff line number Diff line change
@@ -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")
2 changes: 1 addition & 1 deletion examples/report_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ def receivede():
report.get_received("3289406737")

def users():
report.get_users("DAY","2016-04-10","3")
report.get_users("DAY","2016-04-10","3")
2 changes: 1 addition & 1 deletion examples/schedule_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
schedule.put_schedule(schedulepayload,"17349f00-0852-11e6-91b1-0021f653c902")
1 change: 1 addition & 0 deletions jpush/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit d434123

Please sign in to comment.