使用第三方,核心点 看API接口文档
一、短信验证
1.APIID
2.APIKEY
3.接口文档
(1)、看文档说明
(2)、看demo
(3)、先写测试代码,然后集成到项目中
import requests
url = ‘http://106.ihuyi.com/webservice/sms.php?method=Submit’
accounts = ‘C17975236’ # 用户名 APIID
passwords = ‘xxxxxxx’ # 密码 APIKEY
mobiles = ‘33333333’ # 接收人的电话号码
contents = ‘您的验证码是:1234。请不要把验证码泄露给其他人。’
#post请求需要的参数
datas = {
‘account’: accounts,
‘password’: passwords,
‘mobile’: mobiles,
‘content’: contents,
}
header = {“Content-type”: “application/x-www-form-urlencoded”, “Accept”: “text/plain”}
response = requests.post(url=url, data=datas, headers=header)
print(response.content.decode()) # 返回的字符串