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
07c0f3da
Commit
07c0f3da
authored
Dec 13, 2013
by
linbo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add report received API
parent
2fbc680c
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
66 additions
and
3 deletions
+66
-3
push_api.py
examples/push_api.py
+0
-0
recv_api.py
examples/recv_api.py
+6
-0
__init__.py
jpush/__init__.py
+4
-3
push.py
jpush/push.py
+3
-0
recv.py
jpush/recv.py
+53
-0
No files found.
examples/
example
.py
→
examples/
push_api
.py
View file @
07c0f3da
File moved
examples/recv_api.py
0 → 100644
View file @
07c0f3da
from
jpush
import
RecvClient
recv_client
=
RecvClient
(
'appkey'
,
'master_secret'
)
recv_client
.
get_recv
([
0
,
1
,
2
])
recv_client
.
get_recv
(
'0,1,2'
)
jpush/__init__.py
View file @
07c0f3da
from
.client
import
JPushClient
from
.push
import
JPushClient
from
.recv
import
RecvClient
__version__
=
'2.0.
0
'
__version__
=
'2.0.
1
'
VERSION
=
tuple
(
map
(
int
,
__version__
.
split
(
'.'
)))
__all__
=
[
'JPushClient'
]
__all__
=
[
'JPushClient'
,
'RecvClient'
]
jpush/
client
.py
→
jpush/
push
.py
View file @
07c0f3da
# -*- coding: utf-8 -*-
#
# Push API
#
import
json
import
hashlib
...
...
jpush/recv.py
0 → 100644
View file @
07c0f3da
# -*- coding: utf-8 -*-
#
# Report Received API
#
import
httplib
API_HOST
=
"report.jpush.cn"
API_PATH
=
"/v2/received"
class
RecvClient
:
""" JPush Report Received Python Client Class"""
def
__init__
(
self
,
appkey
,
master_secret
,
timeout
=
5
):
self
.
_timeout
=
timeout
self
.
_auth
=
(
"
%
s:
%
s"
%
(
appkey
,
master_secret
))
.
encode
(
"base64"
)
.
strip
()
self
.
_conn
=
None
self
.
_reconnect
()
def
_reconnect
(
self
):
if
self
.
_conn
is
None
:
self
.
_conn
=
httplib
.
HTTPSConnection
(
API_HOST
,
timeout
=
self
.
_timeout
)
def
close
(
self
):
"""close connection"""
if
self
.
_conn
:
self
.
_conn
.
close
()
def
__del__
(
self
):
try
:
self
.
close
()
except
:
pass
def
get_recv
(
self
,
msg_ids
):
"""get recv result"""
if
isinstance
(
msg_ids
,
list
):
msg_ids
=
[
str
(
i
)
for
i
in
msg_ids
]
msg_ids
=
","
.
join
(
msg_ids
)
url
=
"
%
s?msg_ids=
%
s"
%
(
API_PATH
,
msg_ids
)
auth_header
=
{
"Authorization"
:
"Basic
%
s"
%
self
.
_auth
}
if
self
.
_conn
is
None
:
self
.
_reconnect
()
try
:
self
.
_conn
.
request
(
method
=
"GET"
,
url
=
url
,
headers
=
auth_header
)
print
self
.
_conn
.
getresponse
()
.
read
()
except
Exception
,
e
:
self
.
_conn
=
None
print
"Request receive result error:
%
s"
%
e
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