Skip to content

readthecodes/jpush-api-python-client

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

image

image

image

Downloads

JPush API Python Client

JPush's officially supported Python client library for accessing JPush APIs.

JPush Rest API Documents: http://docs.jpush.cn/display/dev/REST+API

You can download the latest release file here: Releases

Dependencies

You need to install requests and pycurl, the python http library, to use jpush python client, and nose for test.

$ sudo pip install -r requirements.txt

Installation

To install jpush-api-python-client, simply:

$ sudo pip install jpush

or alternatively install via easy_install:

$ sudo easy_install jpush

or from source:

$ sudo python setup.py install

Testing

For running the tests, you need the standard unittest module, shipped with Python.

To run jpush-api-python-client tests, simply:

$ nosetests tests/push tests/devices tests/jmessage --verbosity=2 

Examples

You can see more examples in examples

Simple iOS Push

>>> 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 >>> ios_msg = jpush.ios(alert="Hello, IOS JPush!", badge="+1", sound="a.caf", extras={'k1':'v1'}) >>> push.notification = jpush.notification(alert="Hello, JPush!", android=android_msg, ios=ios_msg) >>> push.options = {"time_to_live":86400, "sendno":12345,"apns_production":True} >>> push.platform = jpush.platform("ios") >>> push.send()

Get taglist

>>> 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()

JMessage Users Management ----------------- >>> from jmessage import JMessageSDK >>> import conf >>> sdk = JMessageSDK(conf.APPKEY, conf.MASTERSECRET) >>> sdk.users.register_users('user', [{'username': 'example', 'password': 123456}]) [{u'username': u'example'}] >>> sdk.users.del_user('example') True

JMessage Groups Management ----------------- >>> from jmessage import JMessageSDK >>> import conf >>> sdk = JMessageSDK(conf.APPKEY, conf.MASTERSECRET) >>> sdk.groups.create_group( ... 'example_group_owner@py', ... 'PyCon', ... members_username=['example_user_01@py', 'example_user_02@py'], ... group_desc="Conf for Pythonista!") { u'gid': 10003868, u'members_username': [u'example_user_01@py', u'example_user_02@py'], u'group_desc': u'Conf for Pythonista!', u'owner_username': u'example_group_owner@py', u'group_name': u'PyCon' } >>> sdk.groups.del_group(10003868) True

--------Questions --------The best place to ask questions is our Q&A site: http://www.jpush.cn/qa/

--------Thanks to --------crystal-wei for reporting the jpush-api-python-client issues;

About

JPush's officially supported Python client library for accessing JPush APIs. 极光推送官方支持的 Python 版本服务器端 SDK。

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 100.0%