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
99517e92
Commit
99517e92
authored
Sep 01, 2014
by
hupantingxue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add device api sample;
parent
cf31124d
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
92 additions
and
11 deletions
+92
-11
conf.py
examples/device/conf.py
+2
-0
example_clrtag.py
examples/device/example_clrtag.py
+8
-0
example_getdevice.py
examples/device/example_getdevice.py
+7
-0
example_rmtag.py
examples/device/example_rmtag.py
+6
-0
example_tagexist.py
examples/device/example_tagexist.py
+6
-0
example_taglist.py
examples/device/example_taglist.py
+6
-0
example_tagupduser.py
examples/device/example_tagupduser.py
+6
-0
example_updevice.py
examples/device/example_updevice.py
+8
-0
__init__.py
jpush/__init__.py
+1
-1
common.py
jpush/common.py
+1
-0
core.py
jpush/core.py
+1
-1
core.py
jpush/device/core.py
+39
-8
setup.py
setup.py
+1
-1
No files found.
examples/device/conf.py
0 → 100644
View file @
99517e92
app_key
=
u'dd1066407b044738b6479275'
master_secret
=
u'2b38ce69b1de2a7fa95706ea'
examples/device/example_clrtag.py
0 → 100644
View file @
99517e92
import
jpush
as
jpush
from
conf
import
app_key
,
master_secret
_jpush
=
jpush
.
JPush
(
app_key
,
master_secret
)
device
=
_jpush
.
create_device
()
reg_id
=
'090c1f59f89'
entity
=
jpush
.
device_tag
(
""
)
device
.
set_deviceinfo
(
reg_id
,
entity
)
examples/device/example_getdevice.py
0 → 100644
View file @
99517e92
import
jpush
as
jpush
from
conf
import
app_key
,
master_secret
_jpush
=
jpush
.
JPush
(
app_key
,
master_secret
)
device
=
_jpush
.
create_device
()
reg_id
=
'090c1f59f89'
device
.
get_deviceinfo
(
reg_id
)
examples/device/example_rmtag.py
0 → 100644
View file @
99517e92
import
jpush
as
jpush
from
conf
import
app_key
,
master_secret
_jpush
=
jpush
.
JPush
(
app_key
,
master_secret
)
device
=
_jpush
.
create_device
()
device
.
delete_tag
(
tag
)
examples/device/example_tagexist.py
0 → 100644
View file @
99517e92
import
jpush
as
jpush
from
conf
import
app_key
,
master_secret
_jpush
=
jpush
.
JPush
(
app_key
,
master_secret
)
device
=
_jpush
.
create_device
()
device
.
get_taglist
()
examples/device/example_taglist.py
0 → 100644
View file @
99517e92
import
jpush
as
jpush
from
conf
import
app_key
,
master_secret
_jpush
=
jpush
.
JPush
(
app_key
,
master_secret
)
device
=
_jpush
.
create_device
()
device
.
get_taglist
()
examples/device/example_tagupduser.py
0 → 100644
View file @
99517e92
import
jpush
as
jpush
from
conf
import
app_key
,
master_secret
_jpush
=
jpush
.
JPush
(
app_key
,
master_secret
)
device
=
_jpush
.
create_device
()
device
.
get_taglist
()
examples/device/example_updevice.py
0 → 100644
View file @
99517e92
import
jpush
as
jpush
from
conf
import
app_key
,
master_secret
_jpush
=
jpush
.
JPush
(
app_key
,
master_secret
)
device
=
_jpush
.
create_device
()
reg_id
=
'090c1f59f89'
entity
=
jpush
.
device_tag
(
jpush
.
add
(
"ddd"
,
"tageee"
))
device
.
set_deviceinfo
(
reg_id
,
entity
)
jpush/__init__.py
View file @
99517e92
...
@@ -22,7 +22,7 @@ from .push import (
...
@@ -22,7 +22,7 @@ from .push import (
message
,
message
,
)
)
from
device
import
(
from
.
device
import
(
Device
,
Device
,
add
,
add
,
remove
,
remove
,
...
...
jpush/common.py
View file @
99517e92
...
@@ -8,6 +8,7 @@ PUSH_URL = BASE_URL + 'v3/push'
...
@@ -8,6 +8,7 @@ PUSH_URL = BASE_URL + 'v3/push'
DEVICE_BASEURL
=
"https://device.jpush.cn/"
DEVICE_BASEURL
=
"https://device.jpush.cn/"
DEVICE_URL
=
DEVICE_BASEURL
+
"v3/device/"
DEVICE_URL
=
DEVICE_BASEURL
+
"v3/device/"
TAG_URL
=
DEVICE_BASEURL
+
"v3/tag/"
TAG_URL
=
DEVICE_BASEURL
+
"v3/tag/"
TAGLIST_URL
=
TAG_URL
+
"list/"
ALIAS_URL
=
DEVICE_BASEURL
+
"v3/alias/"
ALIAS_URL
=
DEVICE_BASEURL
+
"v3/alias/"
logger
=
logging
.
getLogger
(
'jpush'
)
logger
=
logging
.
getLogger
(
'jpush'
)
...
...
jpush/core.py
View file @
99517e92
...
@@ -6,7 +6,7 @@ import requests
...
@@ -6,7 +6,7 @@ import requests
from
.
import
common
from
.
import
common
from
.push
import
Push
from
.push
import
Push
from
device
import
Device
from
.
device
import
Device
logger
=
logging
.
getLogger
(
'jpush'
)
logger
=
logging
.
getLogger
(
'jpush'
)
...
...
jpush/device/core.py
View file @
99517e92
#!/usr/bin/env python
#!/usr/bin/env python
#from jpush import common
from
jpush
import
common
import
json
DEVICE_BASEURL
=
"https://device.jpush.cn/"
DEVICE_BASEURL
=
"https://device.jpush.cn/"
DEVICE_URL
=
DEVICE_BASEURL
+
"v3/device/"
DEVICE_URL
=
DEVICE_BASEURL
+
"v3/device/"
TAG_URL
=
DEVICE_BASEURL
+
"v3/tag/"
TAG_URL
=
DEVICE_BASEURL
+
"v3/tag/"
TAGLIST_URL
=
TAG_URL
+
"list/"
ALIAS_URL
=
DEVICE_BASEURL
+
"v3/alias/"
ALIAS_URL
=
DEVICE_BASEURL
+
"v3/alias/"
class
Device
(
object
):
class
Device
(
object
):
...
@@ -14,20 +16,46 @@ class Device(object):
...
@@ -14,20 +16,46 @@ class Device(object):
self
.
_jpush
=
jpush
self
.
_jpush
=
jpush
self
.
entity
=
None
self
.
entity
=
None
def
send
(
self
,
method
,
url
,
body
,
params
,
content_type
=
None
,
version
=
3
):
def
send
(
self
,
method
,
url
,
body
,
content_type
=
None
,
version
=
3
):
"""Send the request
"""Send the request
"""
"""
response
=
self
.
_jpush
.
_request
(
method
,
body
,
response
=
self
.
_jpush
.
_request
(
method
,
body
,
url
,
content_type
,
version
=
3
)
url
,
content_type
,
version
=
3
)
data
=
response
.
json
()
return
DeviceResponse
(
response
)
return
DeviceResponse
(
response
)
def
get_taglist
(
self
):
"""Get deviceinfo with registration id.
"""
url
=
common
.
TAGLIST_URL
info
=
self
.
send
(
"GET"
,
url
,
None
)
print
info
def
get_deviceinfo
(
self
,
registration_id
):
def
get_deviceinfo
(
self
,
registration_id
):
"""Get deviceinfo with registration id
"""Get deviceinfo with registration id.
"""
url
=
common
.
DEVICE_URL
+
registration_id
+
"/"
info
=
self
.
send
(
"GET"
,
url
,
None
)
print
info
def
set_deviceinfo
(
self
,
registration_id
,
entity
):
"""Update deviceinfo with registration id.
"""
url
=
common
.
DEVICE_URL
+
registration_id
+
"/"
body
=
json
.
dumps
(
entity
)
print
url
,
body
info
=
self
.
send
(
"POST"
,
url
,
body
)
print
info
def
delete_tag
(
self
,
registration_id
,
tag
):
"""Delete registration id tag.
"""
"""
url
=
DEVICE_URL
+
registration_id
url
=
common
.
DEVICE_URL
+
registration_id
+
"/"
info
=
self
.
send
(
"GET"
,
None
,
None
)
body
=
json
.
dumps
(
entity
)
print
url
,
body
info
=
self
.
send
(
"POST"
,
url
,
body
)
print
info
print
info
class
DeviceResponse
(
object
):
class
DeviceResponse
(
object
):
...
@@ -41,8 +69,11 @@ class DeviceResponse(object):
...
@@ -41,8 +69,11 @@ class DeviceResponse(object):
payload
=
None
payload
=
None
def
__init__
(
self
,
response
):
def
__init__
(
self
,
response
):
data
=
response
.
json
()
if
0
!=
len
(
response
.
content
):
self
.
payload
=
data
data
=
response
.
json
()
self
.
payload
=
data
elif
200
==
response
.
status_code
:
self
.
payload
=
"success"
def
__str__
(
self
):
def
__str__
(
self
):
return
"Device response Payload: {0}"
.
format
(
self
.
payload
)
return
"Device response Payload: {0}"
.
format
(
self
.
payload
)
setup.py
View file @
99517e92
...
@@ -18,7 +18,7 @@ setup(
...
@@ -18,7 +18,7 @@ setup(
author
=
'jpush'
,
author
=
'jpush'
,
author_email
=
'support@jpush.cn'
,
author_email
=
'support@jpush.cn'
,
packages
=
[
'jpush'
,
'jpush.push'
],
packages
=
[
'jpush'
,
'jpush.push'
,
'jpush.device'
],
platforms
=
'any'
,
platforms
=
'any'
,
classifiers
=
[
classifiers
=
[
'Environment :: Console'
,
'Environment :: Console'
,
...
...
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