python发送短信
时间:2020-06-18 13:54:23
收藏:0
阅读:78
目的:
使用手机号验证码形式登陆。
使用的接口平台(免费的):
https://www.twilio.com
# 进入这个网站,注册账户,验证手机号,填写信息,之后会分配给你一个发送验证码的手机号及两个密钥
安装模块:
pip install twilio
封装好的代码:
def send_veri_code(to_phone, code): from twilio.rest import Client account_sid = "平台获取" auth_token = "平台获取" client = Client(account_sid, auth_token) client.messages.create( to=to_phone, from_="平台获取这个主动发送短信的手机号", body="您的验证码是:%s" % code ) if __name__ == ‘__main__‘: # 发送给的手机号 phone = ‘+86152*********‘ verification_code = ‘1234‘ send_veri_code(phone, verigication_code)
原文:https://www.cnblogs.com/zezhou/p/13157039.html
评论(0)