Skip to content

Commit

Permalink
import json module and fixed json ascii ensure
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick95 committed Oct 12, 2016
1 parent 70addff commit f0e73aa
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 3 deletions.
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
# alidayu
阿里大鱼短信接口,python3
阿里大鱼短信接口,python3 (Perfectly for python3.5)

# 用法

与TOP(淘宝开放平台)提供的SDK用法差不多,实现代码大幅简化,不过只支持python3。

# -*- coding: utf-8 -*-
from alidayu import AlibabaAliqinFcSmsNumSendRequest
import json

# 其中appkey和secret是必须的参数
# url可选,默认为沙箱的URL,正式应用请传入 https://eco.taobao.com/router/rest
# partner_id为可选,其值为下载的TOP SDK中的top/api/base.py里的SYSTEM_GENERATE_VERSION
req=AlibabaAliqinFcSmsNumSendRequest(appkey, secret, url, partner_id)
params = {
'a' : '1',
'b' : '2',
} #短信内容参数(字典)
req.extend="123456"
req.sms_type="normal"
req.sms_free_sign_name="注册验证"
req.sms_param=json.dumps(params)
req.sms_param=json.dumps(params,ensure_ascii=False)
req.rec_num="13000000000"
req.sms_template_code="SMS_5410290"
try:
Expand Down
30 changes: 30 additions & 0 deletions demo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# -*- coding: utf-8 -*-
from alidayu import AlibabaAliqinFcSmsNumSendRequest
import json

# 其中appkey和secret是必须的参数
# url可选,默认为沙箱的URL,正式应用请传入 https://eco.taobao.com/router/rest
# partner_id为可选,其值为下载的TOP SDK中的top/api/base.py里的SYSTEM_GENERATE_VERSION

appkey = ''
secret = ''
url = 'https://eco.taobao.com/router/rest'
partner_id = '' #可选
#短信内容参数
params = {
'a' : '1',
'b' : '2'
}

req = AlibabaAliqinFcSmsNumSendRequest(appkey, secret, url, partner_id)
req.extend = "123456"
req.sms_type = "normal"
req.sms_free_sign_name = "注册验证"
req.sms_param = json.dumps(params,ensure_ascii=False)
req.rec_num = "13000000000"
req.sms_template_code = "SMS_5410290"
try:
resp = req.getResponse()
print(resp)
except Exception as e:
print(e)

0 comments on commit f0e73aa

Please sign in to comment.