Skip to content

Commit d434123

Browse files
author
Helperhaps
committed
add group push example
1 parent f5ff233 commit d434123

File tree

5 files changed

+31
-4
lines changed

5 files changed

+31
-4
lines changed

examples/__init__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@
1010
from . import push_example
1111
from . import report_example
1212
from . import schedule_example
13+
from . import group_push_example
1314

1415
__all__ = [
1516
device_example,
1617
push_example,
1718
report_example,
18-
schedule_example
19-
]
19+
schedule_example,
20+
group_push_example
21+
]

examples/group_push_example.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
from . import jpush
2+
from jpush import common
3+
4+
group_key = u'xxxxxx'
5+
group_secret = u'xxxxxx'
6+
7+
group = jpush.GroupPush(group_key, group_secret)
8+
group.set_logging("DEBUG")
9+
10+
def all():
11+
push = group.create_push()
12+
push.audience = jpush.all_
13+
push.notification = jpush.notification(alert="!hello python jpush api")
14+
push.platform = jpush.all_
15+
try:
16+
response=push.send()
17+
except common.Unauthorized:
18+
raise common.Unauthorized("Unauthorized")
19+
except common.APIConnectionException:
20+
raise common.APIConnectionException("conn")
21+
except common.JPushFailure:
22+
print ("JPushFailure")
23+
except:
24+
print ("Exception")

examples/report_example.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ def receivede():
1111
report.get_received("3289406737")
1212

1313
def users():
14-
report.get_users("DAY","2016-04-10","3")
14+
report.get_users("DAY","2016-04-10","3")

examples/schedule_example.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,4 @@ def put_schedule():
3434

3535
trigger=jpush.schedulepayload.trigger("2016-05-17 12:00:00")
3636
schedulepayload=jpush.schedulepayload.schedulepayload("update a new name", True, trigger, push)
37-
schedule.put_schedule(schedulepayload,"17349f00-0852-11e6-91b1-0021f653c902")
37+
schedule.put_schedule(schedulepayload,"17349f00-0852-11e6-91b1-0021f653c902")

jpush/core.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
class JPush(object):
1717
def __init__(self, key, secret):
1818
self.key = key
19+
print(key)
1920
self.secret = secret
2021
self.session = requests.Session()
2122
self.session.auth = (key, secret)

0 commit comments

Comments
 (0)