JMessage API Python SDK

Github

Introduction

This is the Python development package for the JMessage REST API, which is provided by the JPush officially and generally supports the latest API features.

Corresponding REST API documentation:https://docs.jiguang.cn/jmessage/server/rest_api_im/

Support

Python 2.7

Installation

Install Pip

  1. pip install jmessage

Run after downloading

  1. python setup.py install

Samples

The following code is taken from example/users/regist_user.py under the project directory

  1. from jmessage import users
  2. from jmessage import common
  3. from conf import *
  4. import json
  5. jmessage=common.JMessage(app_key,master_secret)
  6. users=jmessage.create_users()
  7. user= [users.build_user("user","password")]
  8. response=users.regist_user(user)
  9. print (response.content)

The following code is taken from the example/messages/send_message.py under the project directory

  1. from jmessage import users
  2. from jmessage import common
  3. from conf import *
  4. jmessage=common.JMessage(app_key,master_secret)
  5. messages=jmessage.create_messages()
  6. message=messages.build_message(1,"single","admin","text",
  7. "xiaohuihui","admin","Hello, JMessage!")
  8. response=messages.send_messages(message)
  9. print (response.content)

The following code is taken from example/groups/create_groups.py under the project directory

  1. from jmessage import users
  2. from jmessage import common
  3. from conf import *
  4. jmessage=common.JMessage(app_key,master_secret)
  5. groups=jmessage.create_groups()
  6. group=groups.build_group(owner_username="dev_fang", name="jpush",
  7. members_username=["xiaohuihui"], desc="jpush group")
  8. response=groups.create_group(group)
  9. print (response.content)