Skip to main content

JSMS's officially supported Python client library

Project description

# JSMS API PYTHON CLIENT

这是短信 API 的 Python 版本封装开发包,是由极光官方提供的,一般支持最新的 API 功能。支持 Python 2.7 和 Python 3 常见版本。

对应的 API 文档:https://docs.jiguang.cn/jsms/server/rest_api_summary/

## Installing

`bash $ pip install jsms `

## Usage

### 初始化

`python import jsms jsms_client = jsms.Jsms(app_key, master_secret) `

### 发送验证码

`python jsms_client.send_code(mobile, temp_id) `

参数说明:

> mobile: 接收验证码的手机号码

> temp_id: 模板ID

### 发送语音短信验证码

`python jsms_client.send_voice_code(mobile, code=None, lang=None, ttl=None) `

参数说明:

> mobile: 接收验证码的手机号码

> ttl: 超时时间,默认为 60 秒

> code: 语音验证码的值,验证码仅支持 4-8 个数字

> lang: 播报语言选择,0:中文播报,1:英文播报,2:中英混合播报

### 验证

`python jsms_client.verify_code( msg_id, code); `

参数说明:

> msg_id: 发送验证码 send_code/send_voice_code 函数返回的数组中的 msg_id 键对应的值

> code: 手机接收到的验证码

### 发送模板短信

`python jsms_client.send_teml(mobile, temp_id, temp_para=None, time=None) `

参数说明:

> mobile: 接收验证码的手机号码

> temp_id: 模板 ID

> temp_para: 模板参数,需要替换的参数名和 value 的键值对,接受一个 dict

> time: 定时短信发送时间,格式为 yyyy-MM-dd HH:mm:ss,默认为 None 表示立即发送

### 查询定时模板短信

`python jsms_client.show_schedule_message(schedule_id) `

### 删除定时模板短信

`python jsms_client.delete_schedule_message(schedule_id) `

### 应用余量查询

`python jsms_client.app_balance() `

### 调用返回码说明

https://docs.jiguang.cn/jsms/server/rest_api_summary/#_1

## Example

在项目的 [examples](https://github.com/jpush/jsms-api-python-client/tree/master/examples) 文件夹有简单示例代码, 开发者可以参考其中的样例快速了解该库的使用方法。

### 简单使用方法

  • 复制 config.py 文件

`bash $ cp config.py.example config.py `

  • 编辑 config.py 文件,填写信息

`python app_key = 'xxxx' master_secret = 'xxxx' mobile = 'xxxx' `

  • 运行示例

`bash $ python examples/sms.py text_code $ python examples/sms.py voice_code $ python examples/sms.py tmpl_task $ python examples/sms.py blance `

## Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/jpush/jsms-api-python-client.

## License

The library is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jsms-0.0.4.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

jsms-0.0.4-py2.py3-none-any.whl (4.2 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file jsms-0.0.4.tar.gz.

File metadata

  • Download URL: jsms-0.0.4.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.2

File hashes

Hashes for jsms-0.0.4.tar.gz
Algorithm Hash digest
SHA256 18b88a9f004501951dc31c5aee2339dd5428a2cf9572ef5996fc8dd99f891a78
MD5 0f3f0adb8599d36adf181de63f57dc08
BLAKE2b-256 718b34a3159d12bf8e67d16536e839194c97453af839db0d0bb75ed75066f430

See more details on using hashes here.

File details

Details for the file jsms-0.0.4-py2.py3-none-any.whl.

File metadata

  • Download URL: jsms-0.0.4-py2.py3-none-any.whl
  • Upload date:
  • Size: 4.2 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.2

File hashes

Hashes for jsms-0.0.4-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 25fe594da76f5aec612244d6649621c9b20c0d3a0603af4f9f0574f759624604
MD5 7c2f495d1bc1e30086139f217a41cca0
BLAKE2b-256 472c1475225da3bd1e304cc1400287a5480a25a1567244a95360e6daa967ca7c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page