Skip to content

Commit 644fe18

Browse files
author
Helperhaps
committed
add zone examples
1 parent ca179c9 commit 644fe18

File tree

2 files changed

+42
-1
lines changed

2 files changed

+42
-1
lines changed

Diff for: examples/__init__.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,14 @@
1212
from . import schedule_example
1313
from . import group_push_example
1414
from . import admin_example
15+
from . import zone_example
1516

1617
__all__ = [
1718
device_example,
1819
push_example,
1920
report_example,
2021
schedule_example,
2122
group_push_example,
22-
admin_example
23+
admin_example,
24+
zone_example,
2325
]

Diff for: examples/zone_example.py

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
from . import jpush, app_key, master_secret
2+
3+
def default():
4+
_jpush = jpush.JPush(app_key, master_secret)
5+
_jpush.set_logging("DEBUG")
6+
7+
push = _jpush.create_push()
8+
push.audience = jpush.all_
9+
push.notification = jpush.notification(alert="!hello python jpush api")
10+
push.platform = jpush.all_
11+
try:
12+
response=push.send()
13+
except common.Unauthorized:
14+
raise common.Unauthorized("Unauthorized")
15+
except common.APIConnectionException:
16+
raise common.APIConnectionException("conn")
17+
except common.JPushFailure:
18+
print ("JPushFailure")
19+
except:
20+
print ("Exception")
21+
22+
def bj():
23+
_jpush = jpush.JPush(app_key, master_secret, zone = 'bj')
24+
_jpush.set_logging("DEBUG")
25+
26+
push = _jpush.create_push()
27+
push.audience = jpush.all_
28+
push.notification = jpush.notification(alert="!hello python jpush api")
29+
push.platform = jpush.all_
30+
try:
31+
response=push.send()
32+
except common.Unauthorized:
33+
raise common.Unauthorized("Unauthorized")
34+
except common.APIConnectionException:
35+
raise common.APIConnectionException("conn")
36+
except common.JPushFailure:
37+
print ("JPushFailure")
38+
except:
39+
print ("Exception")

0 commit comments

Comments
 (0)