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
ee41857a
Commit
ee41857a
authored
Sep 02, 2014
by
hupantingxue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tags server sample;
parent
99517e92
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
72 additions
and
14 deletions
+72
-14
example_aliasuser.py
examples/device/example_aliasuser.py
+8
-0
example_rmalias.py
examples/device/example_rmalias.py
+3
-2
example_rmtag.py
examples/device/example_rmtag.py
+5
-1
example_tagexist.py
examples/device/example_tagexist.py
+3
-1
example_tagupduser.py
examples/device/example_tagupduser.py
+3
-1
conf.py
examples/push/conf.py
+0
-0
example_all.py
examples/push/example_all.py
+0
-0
example_audience.py
examples/push/example_audience.py
+0
-0
example_options.py
examples/push/example_options.py
+0
-0
core.py
jpush/device/core.py
+44
-3
entity.py
jpush/device/entity.py
+6
-6
No files found.
examples/device/example_aliasuser.py
0 → 100644
View file @
ee41857a
import
jpush
as
jpush
from
conf
import
app_key
,
master_secret
_jpush
=
jpush
.
JPush
(
app_key
,
master_secret
)
device
=
_jpush
.
create_device
()
alias
=
"alias1"
platform
=
"android,ios"
device
.
get_aliasuser
(
alias
,
platform
)
examples/
example_device
.py
→
examples/
device/example_rmalias
.py
View file @
ee41857a
...
@@ -3,5 +3,6 @@ from conf import app_key, master_secret
...
@@ -3,5 +3,6 @@ from conf import app_key, master_secret
_jpush
=
jpush
.
JPush
(
app_key
,
master_secret
)
_jpush
=
jpush
.
JPush
(
app_key
,
master_secret
)
device
=
_jpush
.
create_device
()
device
=
_jpush
.
create_device
()
reg_id
=
'090c1f59f89'
alias
=
"alias1"
device
.
get_deviceinfo
(
reg_id
)
platform
=
"android,ios"
device
.
delete_alias
(
alias
,
platform
)
examples/device/example_rmtag.py
View file @
ee41857a
#-*- encoding:utf-8 -*-
import
jpush
as
jpush
import
jpush
as
jpush
from
conf
import
app_key
,
master_secret
from
conf
import
app_key
,
master_secret
_jpush
=
jpush
.
JPush
(
app_key
,
master_secret
)
_jpush
=
jpush
.
JPush
(
app_key
,
master_secret
)
device
=
_jpush
.
create_device
()
device
=
_jpush
.
create_device
()
device
.
delete_tag
(
tag
)
tag
=
"ddd"
platform
=
"android,ios"
device
.
delete_tag
(
tag
,
platform
)
examples/device/example_tagexist.py
View file @
ee41857a
...
@@ -3,4 +3,6 @@ from conf import app_key, master_secret
...
@@ -3,4 +3,6 @@ from conf import app_key, master_secret
_jpush
=
jpush
.
JPush
(
app_key
,
master_secret
)
_jpush
=
jpush
.
JPush
(
app_key
,
master_secret
)
device
=
_jpush
.
create_device
()
device
=
_jpush
.
create_device
()
device
.
get_taglist
()
tag
=
"ddd"
registration_id
=
'090c1f59f89'
device
.
check_taguserexist
(
tag
,
registration_id
)
examples/device/example_tagupduser.py
View file @
ee41857a
...
@@ -3,4 +3,6 @@ from conf import app_key, master_secret
...
@@ -3,4 +3,6 @@ from conf import app_key, master_secret
_jpush
=
jpush
.
JPush
(
app_key
,
master_secret
)
_jpush
=
jpush
.
JPush
(
app_key
,
master_secret
)
device
=
_jpush
.
create_device
()
device
=
_jpush
.
create_device
()
device
.
get_taglist
()
tag
=
"ddd"
entity
=
jpush
.
device_regid
(
jpush
.
add
(
"090c1f59f89"
))
device
.
update_tagusers
(
tag
,
entity
)
examples/conf.py
→
examples/
push/
conf.py
View file @
ee41857a
File moved
examples/example_all.py
→
examples/
push/
example_all.py
View file @
ee41857a
File moved
examples/example_audience.py
→
examples/
push/
example_audience.py
View file @
ee41857a
File moved
examples/example_options.py
→
examples/
push/
example_options.py
View file @
ee41857a
File moved
jpush/device/core.py
View file @
ee41857a
...
@@ -48,16 +48,57 @@ class Device(object):
...
@@ -48,16 +48,57 @@ class Device(object):
info
=
self
.
send
(
"POST"
,
url
,
body
)
info
=
self
.
send
(
"POST"
,
url
,
body
)
print
info
print
info
def
delete_tag
(
self
,
tag
,
platform
=
None
):
def
delete_tag
(
self
,
registration_id
,
tag
):
"""Delete registration id tag.
"""Delete registration id tag.
"""
"""
url
=
common
.
DEVICE_URL
+
registration_id
+
"/"
url
=
common
.
TAG_URL
+
tag
+
"/"
body
=
None
if
platform
:
body
=
platform
print
url
,
body
info
=
self
.
send
(
"DELETE"
,
url
,
body
)
print
info
def
update_tagusers
(
self
,
tag
,
entity
):
"""Add/Remove specified tag users.
"""
url
=
common
.
TAG_URL
+
tag
+
"/"
body
=
json
.
dumps
(
entity
)
body
=
json
.
dumps
(
entity
)
print
url
,
body
print
url
,
body
info
=
self
.
send
(
"POST"
,
url
,
body
)
info
=
self
.
send
(
"POST"
,
url
,
body
)
print
info
print
info
def
check_taguserexist
(
self
,
tag
,
registration_id
):
"""Check registration id whether in tag.
"""
url
=
common
.
TAG_URL
+
tag
+
"/exist/"
body
=
registration_id
print
url
,
registration_id
info
=
self
.
send
(
"GET"
,
url
,
body
)
print
info
def
delete_alias
(
self
,
alias
,
platform
=
None
):
"""Delete appkey alias.
"""
url
=
common
.
ALIAS_URL
+
alias
+
"/"
body
=
None
if
platform
:
body
=
platform
print
url
,
body
info
=
self
.
send
(
"DELETE"
,
url
,
body
)
print
info
def
get_aliasuser
(
self
,
alias
,
platform
=
None
):
"""Get appkey alias users.
"""
url
=
common
.
ALIAS_URL
+
alias
+
"/"
body
=
None
if
platform
:
body
=
platform
print
url
,
body
info
=
self
.
send
(
"GET"
,
url
,
body
)
print
info
class
DeviceResponse
(
object
):
class
DeviceResponse
(
object
):
"""Response to a successful device request send.
"""Response to a successful device request send.
...
...
jpush/device/entity.py
View file @
ee41857a
...
@@ -75,22 +75,22 @@ def device_regid(*types):
...
@@ -75,22 +75,22 @@ def device_regid(*types):
"""Get a registration_id object
"""Get a registration_id object
>>> device_regid("")
>>> device_regid("")
{'registration_id': ''}
{'registration_id
s
': ''}
>>> device_regid("registration_id1")
>>> device_regid("registration_id1")
{'registration_id': 'registration_id1'}
{'registration_id
s
': 'registration_id1'}
>>> device_regid(add("registration_id1", "registration_id2"), remove("registration_id3", "registration_id4"))
>>> device_regid(add("registration_id1", "registration_id2"), remove("registration_id3", "registration_id4"))
{'registration_id': {'add': ['registration_id1', 'registration_id2'], 'remove': ['registration_id3', 'registration_id4']}}
{'registration_id
s
': {'add': ['registration_id1', 'registration_id2'], 'remove': ['registration_id3', 'registration_id4']}}
"""
"""
registration_id
=
{}
registration_id
=
{}
if
1
==
len
(
types
)
and
isinstance
(
types
[
0
],
(
str
,
unicode
)):
if
1
==
len
(
types
)
and
isinstance
(
types
[
0
],
(
str
,
unicode
)):
registration_id
[
"registration_id"
]
=
types
[
0
]
registration_id
[
"registration_id
s
"
]
=
types
[
0
]
return
registration_id
return
registration_id
registration_id
[
"registration_id"
]
=
{}
registration_id
[
"registration_id
s
"
]
=
{}
for
t
in
types
:
for
t
in
types
:
for
key
in
t
:
for
key
in
t
:
if
key
not
in
(
'add'
,
'remove'
):
if
key
not
in
(
'add'
,
'remove'
):
raise
ValueError
(
"Invalid registration_id '
%
s'"
%
t
)
raise
ValueError
(
"Invalid registration_id '
%
s'"
%
t
)
registration_id
[
"registration_id"
][
key
]
=
t
[
key
]
registration_id
[
"registration_id
s
"
][
key
]
=
t
[
key
]
return
registration_id
return
registration_id
if
"__main__"
==
__name__
:
if
"__main__"
==
__name__
:
...
...
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