云通讯平台-PYTHON短信接口开发示例
#!/usr/bin/python
#2.0+++
import requests#导入request模块
import json
import hashlib
def getSign(password):
str=password
md5=hashlib.md5()
md5.update(str.encode(encoding='utf-8'))
sign=md5.hexdigest()
return sign
user="123123" #你的账号
password=getSign("a123123") # 你的密码
url = 'https://u.smsyun.cc/sms-partner/access/'+user+'/sendsms'
payload= {
"smstype":'4',
"clientid":user,
"password":password,
'mobile':'13941557052',
'content':'【云信】你的验证码是124563'
}#值以字典的形式传入
pdata=json.dumps(payload)
aheaders = {'Accept-Encoding':'identity','Accept':'application/json','Content-Type': 'application/json; charset=utf-8',}
response = requests.post(url=url,headers=aheaders,data=pdata)
print(response.text)