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
32689984
Commit
32689984
authored
Apr 20, 2016
by
fendouai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add sms message and update the device mobile
parent
0646dd79
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
57 additions
and
6 deletions
+57
-6
.gitignore
.gitignore
+1
-0
conf.py
examples/device/conf.py
+2
-2
example_updevice.py
examples/device/example_updevice.py
+2
-2
example_updevicemobile.py
examples/device/example_updevicemobile.py
+8
-0
conf.py
examples/push/conf.py
+2
-2
example_sms.py
examples/push/example_sms.py
+11
-0
__init__.py
jpush/__init__.py
+3
-0
__init__.py
jpush/device/__init__.py
+2
-0
core.py
jpush/device/core.py
+9
-0
entity.py
jpush/device/entity.py
+5
-0
__init__.py
jpush/push/__init__.py
+2
-0
core.py
jpush/push/core.py
+2
-0
payload.py
jpush/push/payload.py
+8
-0
No files found.
.gitignore
View file @
32689984
...
...
@@ -2,4 +2,5 @@
build/
dist/
jpush.egg-info/
.idea/
examples/device/conf.py
View file @
32689984
app_key
=
u'
dd1066407b044738b6479275
'
master_secret
=
u'
2b38ce69b1de2a7fa95706ea
'
app_key
=
u'
6be9204c30b9473e87bad4dc
'
master_secret
=
u'
8aae478411e89f7682ed5af6
'
examples/device/example_updevice.py
View file @
32689984
...
...
@@ -3,7 +3,7 @@ from conf import app_key, master_secret
_jpush
=
jpush
.
JPush
(
app_key
,
master_secret
)
device
=
_jpush
.
create_device
()
reg_id
=
'
090c1f59f89
'
reg_id
=
'
1507bfd3f7c466c355c
'
entity
=
jpush
.
device_tag
(
jpush
.
add
(
"ddd"
,
"tageee"
))
#entity = jpush.device_tag("")
device
.
set_device
info
(
reg_id
,
entity
)
device
.
set_device
mobile
(
reg_id
,
entity
)
examples/device/example_updevicemobile.py
0 → 100644
View file @
32689984
import
jpush
as
jpush
from
conf
import
app_key
,
master_secret
_jpush
=
jpush
.
JPush
(
app_key
,
master_secret
)
device
=
_jpush
.
create_device
()
reg_id
=
'1507bfd3f7c466c355c'
entity
=
jpush
.
device_mobile
(
"18588232140"
)
device
.
set_devicemobile
(
reg_id
,
entity
)
examples/push/conf.py
View file @
32689984
app_key
=
u'
dd1066407b044738b6479275
'
master_secret
=
u'
2b38ce69b1de2a7fa95706ea
'
app_key
=
u'
6be9204c30b9473e87bad4dc
'
master_secret
=
u'
8aae478411e89f7682ed5af6
'
examples/push/example_sms.py
0 → 100644
View file @
32689984
import
jpush
as
jpush
from
conf
import
app_key
,
master_secret
_jpush
=
jpush
.
JPush
(
app_key
,
master_secret
)
push
=
_jpush
.
create_push
()
push
.
audience
=
jpush
.
all_
push
.
notification
=
jpush
.
notification
(
alert
=
"a sms message from python jpush api"
)
push
.
platform
=
jpush
.
all_
push
.
smsmessage
=
jpush
.
smsmessage
(
"a sms message from python jpush api"
,
0
)
print
push
.
payload
push
.
send
()
jpush/__init__.py
View file @
32689984
...
...
@@ -20,6 +20,7 @@ from .push import (
audience
,
options
,
message
,
smsmessage
,
)
from
.device
import
(
...
...
@@ -29,6 +30,7 @@ from .device import (
device_tag
,
device_alias
,
device_regid
,
device_mobile
,
)
__all__
=
[
...
...
@@ -46,6 +48,7 @@ __all__ = [
android
,
winphone
,
message
,
smsmessage
,
platform
,
audience
,
options
,
...
...
jpush/device/__init__.py
View file @
32689984
...
...
@@ -6,6 +6,7 @@ from .entity import (
device_tag
,
device_alias
,
device_regid
,
device_mobile
,
)
__all__
=
[
...
...
@@ -15,4 +16,5 @@ __all__ = [
device_tag
,
device_alias
,
device_regid
,
device_mobile
,
]
jpush/device/core.py
View file @
32689984
...
...
@@ -45,6 +45,15 @@ class Device(object):
print
(
url
),
(
body
),
(
info
)
return
info
def
set_devicemobile
(
self
,
registration_id
,
entity
):
"""Update deviceinfo with registration id.
"""
url
=
common
.
DEVICE_URL
+
registration_id
+
"/"
body
=
json
.
dumps
(
entity
)
info
=
self
.
send
(
"POST"
,
url
,
body
)
print
(
url
),
(
body
),
(
info
)
return
info
def
delete_tag
(
self
,
tag
,
platform
=
None
):
"""Delete registration id tag.
"""
...
...
jpush/device/entity.py
View file @
32689984
...
...
@@ -53,6 +53,11 @@ def device_tag(*types):
tag
[
"tags"
][
key
]
=
t
[
key
]
return
tag
def
device_mobile
(
device_mobile
):
mobile
=
{}
mobile
[
"mobile"
]
=
device_mobile
return
mobile
def
device_alias
(
*
types
):
"""Get an alias object
...
...
jpush/push/__init__.py
View file @
32689984
...
...
@@ -16,6 +16,7 @@ from .payload import (
message
,
audience
,
options
,
smsmessage
,
)
# Common selector for audience & platform
...
...
@@ -38,4 +39,5 @@ __all__ = [
platform
,
audience
,
options
,
smsmessage
,
]
jpush/push/core.py
View file @
32689984
...
...
@@ -15,12 +15,14 @@ class Push(object):
self
.
platform
=
None
self
.
options
=
None
self
.
message
=
None
self
.
smsmessage
=
None
@property
def
payload
(
self
):
data
=
{
"audience"
:
self
.
audience
,
"platform"
:
self
.
platform
,
"sms_message"
:
self
.
smsmessage
,
}
if
(
self
.
notification
is
None
)
and
(
self
.
message
is
None
):
raise
ValueError
(
"Notification and message cannot be both empty"
)
...
...
jpush/push/payload.py
View file @
32689984
...
...
@@ -128,6 +128,14 @@ def message(msg_content, title=None, content_type=None, extras=None):
payload
[
'extras'
]
=
extras
return
payload
def
smsmessage
(
content
,
delay_time
):
payload
=
{}
payload
[
"content"
]
=
content
payload
[
"delay_time"
]
=
delay_time
return
payload
def
platform
(
*
types
):
"""Create a platform specifier.
...
...
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