Skip to content

Commit 3a92b16

Browse files
author
Guo Zijun
committed
py sdk 更新
1 parent cd63f01 commit 3a92b16

File tree

5 files changed

+669
-0
lines changed

5 files changed

+669
-0
lines changed

yunpian/python/README.md

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ypclient: 第二版 py sdk
2+
yunpianSmsClient: 第一版 py sdk

yunpian/python/ypclient/LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2016 Tony Guo
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

yunpian/python/ypclient/README.md

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# yunpian
2+
yunpian api client for python2/3
3+
4+
Dependence: requests>=2.11.0
5+
6+
Features:
7+
8+
1. Persistent connection
9+
2. Support py2/py3
10+
3. Configurable client
11+
12+
13+

yunpian/python/ypclient/demo.py

+103
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# coding: utf8
2+
from datetime import datetime
3+
4+
# 使用V1 API
5+
# from yunpian import ClientV1
6+
# c = ClientV1('your api key')
7+
8+
# 使用V2 API
9+
from yunpian import ClientV2
10+
c = ClientV2('your api key')
11+
12+
#### 账户API
13+
# V1/V2 查看账户信息
14+
res = c.get_account()
15+
16+
# V1/V2 修改账户信息
17+
# res = c.modify_account('name', 'phone', 20)
18+
19+
20+
#### 模板API
21+
# V2 取默认模板
22+
# res = c.get_default_sms_tpl()
23+
24+
# V1/V2 添加模板
25+
# res = c.create_sms_tpl('签名', '模板内容')
26+
27+
# V1/V2 取模板
28+
# res = c.get_sms_tpl(111111)
29+
30+
# V1/V2 修改模板
31+
# res = c.modify_sms_tpl(11111, '新签名', '新模板内容')
32+
33+
# V1/V2 删除模板
34+
# res = c.del_sms_tpl(111111)
35+
36+
37+
#### 短信API
38+
# V1 智能匹配模板发送; V2 单条发送
39+
# res = c.send_sms('151xxxxxxxx', '【签名】短信内容')
40+
41+
# V2 批量发送
42+
# res = c.broadcast_sms(['151xxxxxxx1', '151xxxxxxx2'], '【签名】短信内容')
43+
44+
# V1 批量个性化发送; V2 个性化发送;
45+
# 使用jobs方式配置任务
46+
# res = c.send_multi_sms(jobs=[
47+
# {
48+
# '151xxxxxxx1': '【签名1】短信内容1',
49+
# '151xxxxxxx2': '【签名2】短信内容2',
50+
# },
51+
# {
52+
# '151xxxxxxx2': '【签名3】短信内容3',
53+
# '151xxxxxxx3': '【签名4】短信内容4',
54+
# },
55+
# ])
56+
# 使用流水线方式配置任务
57+
# res = c.send_multi_sms(
58+
# mobiles=['151xxxxxxx1', '151xxxxxxx2', '151xxxxxxx2', '151xxxxxxx3'],
59+
# contents=['【签名1】短信内容1', '【签名2】短信内容2', '【签名3】短信内容3', '【签名4】短信内容4']
60+
# )
61+
62+
# V1/V2 获取状态报告
63+
# res = c.get_sms_status()
64+
65+
# V1/V2 推送状态报告
66+
# res = c.get_sms_reply()
67+
68+
# V1/V2 查回复短信
69+
# res = c.retrieve_sms_reply('2016-08-13 00:00:00', datetime.now(), 20)
70+
71+
# V1/V2 查短信发送记录
72+
# res = c.get_sms_send_record('2016-08-13 00:00:00', datetime.now(), 20)
73+
74+
# V1/V2 查屏蔽词
75+
# res = c.get_black_word('我是大傻逼') # "傻逼"是屏蔽词
76+
77+
# V1 指定模板发送; V2 指定模板单发
78+
# res = c.send_tpl_sms('151xxxxxxxx', 11111, {'context': '模板上下文'})
79+
80+
81+
#### 语音API
82+
# V1/V2 发送语音验证码
83+
# res = c.voice_verification_code('151xxxxxxxx', 112233)
84+
85+
# V1/V2 获取状态报告
86+
# res = c.get_voice_verification_status()
87+
88+
89+
#### 流量API
90+
# V1/V2 查询流量包
91+
# res = c.get_data_traffic()
92+
93+
# V1/V2 流量包充值
94+
# res = c.recharge_data_traffic('151xxxxxxxx', '1008601')
95+
96+
# V1/V2 获取状态报告
97+
# res = c.get_data_traffic_status()
98+
99+
100+
101+
102+
# 读取返回值
103+
data = res.json()

0 commit comments

Comments
 (0)