Commit f5ff2331 authored by Helperhaps's avatar Helperhaps

refactor examples

parent 13cf99fb
import os
import sys
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
import jpush
from .conf import app_key, master_secret
from . import device_example
from . import push_example
from . import report_example
from . import schedule_example
__all__ = [
device_example,
push_example,
report_example,
schedule_example
]
\ No newline at end of file
# please put your app_key and master_secret here # please put your app_key and master_secret here
app_key = u'6be9204c30b9473e87bad4dc' app_key = u'6be9204c30b9473e87bad4dc'
master_secret = u'9349ad7c90292a603c512e92' master_secret = u'cae22120eed6835e486399a7'
from . import jpush, app_key, master_secret
_jpush = jpush.JPush(app_key, master_secret)
_jpush.set_logging("DEBUG")
device = _jpush.create_device()
def alias_user():
alias = "alias1"
platform = "android,ios"
device.get_aliasuser(alias, platform)
def ctrl_tag():
reg_id = '090c1f59f89'
entity = jpush.device_tag("")
device.set_deviceinfo(reg_id, entity)
def get_device():
reg_id = '090c1f59f89'
device.get_deviceinfo(reg_id)
def delete_alias():
alias = "alias1"
platform = "android,ios"
device.delete_alias(alias, platform)
def delete_tag():
tag = "ddd"
platform = "android,ios"
device.delete_tag(tag, platform)
def check_tag():
tag = "ddd"
registration_id = '090c1f59f89'
device.check_taguserexist(tag, registration_id)
def tag_list():
device.get_taglist()
def tag_update_user():
tag = "ddd"
entity = jpush.device_regid(jpush.add("090c1f59f89"))
device.update_tagusers(tag, entity)
def update_device():
reg_id = '1507bfd3f7c466c355c'
entity = jpush.device_tag(jpush.add("ddd", "tageee"))
result=device.set_devicemobile(reg_id, entity)
print (result.status_code)
print (result.payload)
def update_device_mobile():
reg_id = '1507bfd3f7c466c355c'
entity = jpush.device_mobile("18588232140")
device.set_devicemobile(reg_id, entity)
import jpush as jpush
from conf import app_key, master_secret
_jpush = jpush.JPush(app_key, master_secret)
_jpush.set_logging("DEBUG")
device = _jpush.create_device()
alias = "alias1"
platform = "android,ios"
device.get_aliasuser(alias, platform)
import jpush as jpush
from conf import app_key, master_secret
_jpush = jpush.JPush(app_key, master_secret)
_jpush.set_logging("DEBUG")
device = _jpush.create_device()
reg_id = '090c1f59f89'
entity = jpush.device_tag("")
device.set_deviceinfo(reg_id, entity)
import jpush as jpush
from conf import app_key, master_secret
_jpush = jpush.JPush(app_key, master_secret)
_jpush.set_logging("DEBUG")
device = _jpush.create_device()
reg_id = '090c1f59f89'
device.get_deviceinfo(reg_id)
import jpush as jpush
from conf import app_key, master_secret
_jpush = jpush.JPush(app_key, master_secret)
_jpush.set_logging("DEBUG")
device = _jpush.create_device()
alias = "alias1"
platform = "android,ios"
device.delete_alias(alias, platform)
#-*- encoding:utf-8 -*-
import jpush as jpush
from conf import app_key, master_secret
_jpush = jpush.JPush(app_key, master_secret)
_jpush.set_logging("DEBUG")
device = _jpush.create_device()
tag = "ddd"
platform = "android,ios"
device.delete_tag(tag, platform)
import jpush as jpush
from conf import app_key, master_secret
_jpush = jpush.JPush(app_key, master_secret)
_jpush.set_logging("DEBUG")
device = _jpush.create_device()
tag = "ddd"
registration_id = '090c1f59f89'
device.check_taguserexist(tag, registration_id)
import jpush as jpush
from conf import app_key, master_secret
_jpush = jpush.JPush(app_key, master_secret)
_jpush.set_logging("DEBUG")
device = _jpush.create_device()
device.get_taglist()
import jpush as jpush
from conf import app_key, master_secret
_jpush = jpush.JPush(app_key, master_secret)
_jpush.set_logging("DEBUG")
device = _jpush.create_device()
tag = "ddd"
entity = jpush.device_regid(jpush.add("090c1f59f89"))
device.update_tagusers(tag, entity)
import jpush as jpush
from conf import app_key, master_secret
_jpush = jpush.JPush(app_key, master_secret)
_jpush.set_logging("DEBUG")
device = _jpush.create_device()
reg_id = '1507bfd3f7c466c355c'
entity = jpush.device_tag(jpush.add("ddd", "tageee"))
result=device.set_devicemobile(reg_id, entity)
print (result.status_code)
print (result.payload)
\ No newline at end of file
import jpush as jpush
from conf import app_key, master_secret
_jpush = jpush.JPush(app_key, master_secret)
_jpush.set_logging("DEBUG")
device = _jpush.create_device()
reg_id = '1507bfd3f7c466c355c'
entity = jpush.device_mobile("18588232140")
device.set_devicemobile(reg_id, entity)
from . import jpush, app_key, master_secret
_jpush = jpush.JPush(app_key, master_secret)
_jpush.set_logging("DEBUG")
def alias():
push = _jpush.create_push()
alias=["alias1", "alias2"]
alias1={"alias": alias}
print(alias1)
push.audience = jpush.audience(
jpush.tag("tag1", "tag2"),
alias1
)
push.notification = jpush.notification(alert="Hello world with audience!")
push.platform = jpush.all_
print (push.payload)
push.send()
def all():
push = _jpush.create_push()
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")
def audience():
push = _jpush.create_push()
push.audience = jpush.audience(
jpush.tag("tag1", "tag2"),
jpush.alias("alias1", "alias2")
)
push.notification = jpush.notification(alert="Hello world with audience!")
push.platform = jpush.all_
print (push.payload)
push.send()
def notification():
push = _jpush.create_push()
push.audience = jpush.all_
push.platform = jpush.all_
ios = jpush.ios(alert="Hello, IOS JPush!", sound="a.caf", extras={'k1':'v1'})
android = jpush.android(alert="Hello, Android msg", priority=1, style=1, alert_type=1,big_text='jjjjjjjjjj', extras={'k1':'v1'})
push.notification = jpush.notification(alert="Hello, JPush!", android=android, ios=ios)
# pprint (push.payload)
result = push.send()
def options():
push = _jpush.create_push()
push.audience = jpush.all_
push.notification = jpush.notification(alert="Hello, world!")
push.platform = jpush.all_
push.options = {"time_to_live":86400, "sendno":12345,"apns_production":True}
push.send()
def platfrom_msg():
push = _jpush.create_push()
push.audience = jpush.all_
ios_msg = jpush.ios(alert="Hello, IOS JPush!", badge="+1", sound="a.caf", extras={'k1':'v1'})
android_msg = jpush.android(alert="Hello, android msg")
push.notification = jpush.notification(alert="Hello, JPush!", android=android_msg, ios=ios_msg)
push.message=jpush.message("content",extras={'k2':'v2','k3':'v3'})
push.platform = jpush.all_
push.send()
def silent():
push = _jpush.create_push()
push.audience = jpush.all_
ios_msg = jpush.ios(alert="Hello, IOS JPush!", badge="+1", extras={'k1':'v1'}, sound_disable=True)
android_msg = jpush.android(alert="Hello, android msg")
push.notification = jpush.notification(alert="Hello, JPush!", android=android_msg, ios=ios_msg)
push.platform = jpush.all_
push.send()
def sms():
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()
def validate():
push = _jpush.create_push()
push.audience = jpush.all_
push.notification = jpush.notification(alert="Hello, world!")
push.platform = jpush.all_
push.send_validate()
import jpush as jpush
from conf import app_key, master_secret
_jpush = jpush.JPush(app_key, master_secret)
_jpush.set_logging("DEBUG")
push = _jpush.create_push()
alias=["alias1", "alias2"]
alias1={"alias": alias}
print alias1
push.audience = jpush.audience(
jpush.tag("tag1", "tag2"),
alias1
)
push.notification = jpush.notification(alert="Hello world with audience!")
push.platform = jpush.all_
print (push.payload)
push.send()
\ No newline at end of file
import jpush as jpush
from conf import app_key, master_secret
from jpush import common
_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",the 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")
import jpush as jpush
from conf import app_key, master_secret
_jpush = jpush.JPush(app_key, master_secret)
_jpush.set_logging("DEBUG")
push = _jpush.create_push()
push.audience = jpush.audience(
jpush.tag("tag1", "tag2"),
jpush.alias("alias1", "alias2")
)
push.notification = jpush.notification(alert="Hello world with audience!")
push.platform = jpush.all_
print (push.payload)
push.send()
import jpush as jpush
from conf import app_key, master_secret
# from pprint import pprint
_jpush = jpush.JPush(app_key, master_secret)
_jpush.set_logging("DEBUG")
push = _jpush.create_push()
push.audience = jpush.all_
push.platform = jpush.all_
ios = jpush.ios(alert="Hello, IOS JPush!", sound="a.caf", extras={'k1':'v1'})
android = jpush.android(alert="Hello, Android msg", priority=1, style=1, alert_type=1,big_text='jjjjjjjjjj', extras={'k1':'v1'})
push.notification = jpush.notification(alert="Hello, JPush!", android=android, ios=ios)
# pprint (push.payload)
result = push.send()
import jpush as jpush
from conf import app_key, master_secret
_jpush = jpush.JPush(app_key, master_secret)
_jpush.set_logging("DEBUG")
push = _jpush.create_push()
push.audience = jpush.all_
push.notification = jpush.notification(alert="Hello, world!")
push.platform = jpush.all_
push.options = {"time_to_live":86400, "sendno":12345,"apns_production":True}
push.send()
import jpush as jpush
from conf import app_key, master_secret
_jpush = jpush.JPush(app_key, master_secret)
_jpush.set_logging("DEBUG")
push = _jpush.create_push()
push.audience = jpush.all_
ios_msg = jpush.ios(alert="Hello, IOS JPush!", badge="+1", sound="a.caf", extras={'k1':'v1'})
android_msg = jpush.android(alert="Hello, android msg")
push.notification = jpush.notification(alert="Hello, JPush!", android=android_msg, ios=ios_msg)
push.message=jpush.message("content",extras={'k2':'v2','k3':'v3'})
push.platform = jpush.all_
push.send()
import jpush as jpush
from conf import app_key, master_secret
_jpush = jpush.JPush(app_key, master_secret)
_jpush.set_logging("DEBUG")
push = _jpush.create_push()
push.audience = jpush.all_
ios_msg = jpush.ios(alert="Hello, IOS JPush!", badge="+1", extras={'k1':'v1'}, sound_disable=True)
android_msg = jpush.android(alert="Hello, android msg")
push.notification = jpush.notification(alert="Hello, JPush!", android=android_msg, ios=ios_msg)
push.platform = jpush.all_
push.send()
import jpush as jpush
from conf import app_key, master_secret
_jpush = jpush.JPush(app_key, master_secret)
_jpush.set_logging("DEBUG")
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()
import jpush as jpush
from conf import app_key, master_secret
_jpush = jpush.JPush(app_key, master_secret)
_jpush.set_logging("DEBUG")
push = _jpush.create_push()
push.audience = jpush.all_
push.notification = jpush.notification(alert="Hello, world!")
push.platform = jpush.all_
push.send_validate()
from . import jpush, app_key, master_secret
_jpush = jpush.JPush(app_key, master_secret)
_jpush.set_logging("DEBUG")
report=_jpush.create_report()
def messages():
report.get_messages("3289406737")
def receivede():
report.get_received("3289406737")
def users():
report.get_users("DAY","2016-04-10","3")
\ No newline at end of file
import jpush as jpush
from conf import app_key, master_secret
_jpush = jpush.JPush(app_key, master_secret)
_jpush.set_logging("DEBUG")
report=_jpush.create_report();
report.get_messages("3289406737")
\ No newline at end of file
import jpush as jpush
from conf import app_key, master_secret
_jpush = jpush.JPush(app_key, master_secret)
_jpush.set_logging("DEBUG")
report=_jpush.create_report();
report.get_received("3289406737")
\ No newline at end of file
import jpush as jpush
from conf import app_key, master_secret
_jpush = jpush.JPush(app_key, master_secret)
_jpush.set_logging("DEBUG")
report=_jpush.create_report();
report.get_users("DAY","2016-04-10","3")
\ No newline at end of file
from . import jpush, app_key, master_secret
_jpush = jpush.JPush(app_key, master_secret)
_jpush.set_logging("DEBUG")
schedule = _jpush.create_schedule()
def delete_schedule():
schedule.delete_schedule("e9c553d0-0850-11e6-b6d4-0021f652c102")
def get_schedule():
schedule.get_schedule_by_id("e9c553d0-0850-11e6-b6d4-0021f652c102")
def get_schedule():
schedule.get_schedule_list("1")
def post_schedule():
push = _jpush.create_push()
push.audience = jpush.all_
push.notification = jpush.notification(alert="Hello, world!")
push.platform = jpush.all_
push=push.payload
trigger=jpush.schedulepayload.trigger("2016-07-17 12:00:00")
schedulepayload=jpush.schedulepayload.schedulepayload("name",True,trigger,push)
result=schedule.post_schedule(schedulepayload)
print (result.status_code)
def put_schedule():
push = _jpush.create_push()
push.audience = jpush.all_
push.notification = jpush.notification(alert="Hello, world!")
push.platform = jpush.all_
push=push.payload
trigger=jpush.schedulepayload.trigger("2016-05-17 12:00:00")
schedulepayload=jpush.schedulepayload.schedulepayload("update a new name", True, trigger, push)
schedule.put_schedule(schedulepayload,"17349f00-0852-11e6-91b1-0021f653c902")
\ No newline at end of file
import jpush as jpush
from conf import app_key, master_secret
_jpush = jpush.JPush(app_key, master_secret)
_jpush.set_logging("DEBUG")
schedule = _jpush.create_schedule()
schedule.delete_schedule("e9c553d0-0850-11e6-b6d4-0021f652c102")
import jpush as jpush
from conf import app_key, master_secret
_jpush = jpush.JPush(app_key, master_secret)
_jpush.set_logging("DEBUG")
schedule = _jpush.create_schedule()
schedule.get_schedule_by_id("e9c553d0-0850-11e6-b6d4-0021f652c102")
import jpush as jpush
from conf import app_key, master_secret
_jpush = jpush.JPush(app_key, master_secret)
_jpush.set_logging("DEBUG")
schedule = _jpush.create_schedule()
schedule.get_schedule_list("1")
\ No newline at end of file
import jpush as jpush
from conf import app_key, master_secret
_jpush = jpush.JPush(app_key, master_secret)
_jpush.set_logging("DEBUG")
schedule = _jpush.create_schedule()
push = _jpush.create_push()
push.audience = jpush.all_
push.notification = jpush.notification(alert="Hello, world!")
push.platform = jpush.all_
push=push.payload
trigger=jpush.schedulepayload.trigger("2016-07-17 12:00:00")
schedulepayload=jpush.schedulepayload.schedulepayload("name",True,trigger,push)
result=schedule.post_schedule(schedulepayload)
print (result.status_code)
import jpush as jpush
from conf import app_key, master_secret
_jpush = jpush.JPush(app_key, master_secret)
_jpush.set_logging("DEBUG")
schedule = _jpush.create_schedule()
push = _jpush.create_push()
push.audience = jpush.all_
push.notification = jpush.notification(alert="Hello, world!")
push.platform = jpush.all_
push=push.payload
trigger=jpush.schedulepayload.trigger("2016-05-17 12:00:00")
schedulepayload=jpush.schedulepayload.schedulepayload("update a new name", True, trigger, push)
schedule.put_schedule(schedulepayload,"17349f00-0852-11e6-91b1-0021f653c902")
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment