Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
J
jpush-api-python-client
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
钟尚武
jpush-api-python-client
Commits
443fed43
Commit
443fed43
authored
May 17, 2016
by
fendouai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add readme
parent
4439b397
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
62 additions
and
1 deletion
+62
-1
README.md
README.md
+62
-0
example_all.py
examples/push_examples/example_all.py
+0
-1
No files found.
README.md
View file @
443fed43
# JPush API Python Client
## 概述
这是 JPush REST API 的 Python 版本封装开发包,是由极光推送官方提供的,一般支持最新的 API 功能。
对应的 REST API 文档:
<http://docs.jpush.io/server/rest_api_v3_push/>
## 环境配置
*
pip方式:sudo pip install jpush
*
easy_install方式:sudo easy_install jpush
*
使用源码方式:sudo python setup.py install
## 代码样例
>以下片断来自项目代码里的文件:jpush-api-python-client 中的 examples/push_examples 目录下的 example_all.py
>演示了消息推送,日志设置,异常处理。
```
_jpush = jpush.JPush(app_key, master_secret)
push = _jpush.create_push()
# the default logging level is WARNING,if you set the logging level to "DEBUG",it will show the debug logging.
_jpush.set_logging("DEBUG")
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"
```
## 异常说明
+
Unauthorized
+
AppKey,Master Secret 错误,验证失败必须改正。
+
APIConnectionException
+
包含错误的信息:比如超时,无网络等情况。
+
JPushFailure
+
请求出错,参考业务返回码。
## HTTP 状态码
参考文档:
<http://docs.jpush.io/server/http_status_code/>
Push v3 API 状态码 参考文档:
<http://docs.jpush.io/server/rest_api_v3_push/>
Report API 状态码 参考文档:
<http://docs.jpush.io/server/rest_api_v3_report/>
Device API 状态码 参考文档:
<http://docs.jpush.io/server/rest_api_v3_device/>
Push Schedule API 状态码 参考文档:
<http://docs.jpush.io/server/rest_api_push_schedule/>
[
Release页面
](
https://github.com/jpush/jpush-api-python-client/releases
)
有详细的版本发布记录与下载。
examples/push_examples/example_all.py
View file @
443fed43
...
@@ -11,7 +11,6 @@ _jpush.set_logging("DEBUG")
...
@@ -11,7 +11,6 @@ _jpush.set_logging("DEBUG")
push
.
audience
=
jpush
.
all_
push
.
audience
=
jpush
.
all_
push
.
notification
=
jpush
.
notification
(
alert
=
"hello python jpush api"
)
push
.
notification
=
jpush
.
notification
(
alert
=
"hello python jpush api"
)
push
.
platform
=
jpush
.
all_
push
.
platform
=
jpush
.
all_
try
:
try
:
response
=
push
.
send
()
response
=
push
.
send
()
except
common
.
Unauthorized
:
except
common
.
Unauthorized
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment