发送信息的Python代码有了一些变动
注册:
流程基本没变,到处都能搜到
领发送短信的美国手机号那一步,选 Manage Numbers 不用选下面的 Buy a Number 、
发信息的Python代码:
以前是:
from twilio.rest import TwilioRestClient
account_sid = "ACXXXXXXXXXXXXXXXXX"
auth_token = "YYYYYYYYYYYYYYYYYY"
client = TwilioRestClient(account_sid, auth_token)
message = client.messages.create(to="+8615912345678",
from_="+15555555555",
body="python test")
运行之后报错,查询官网https://www.twilio.com/docs/libraries/python Python代码说明,代码已更改为:
from twilio.rest import Client
# Your Account SID from twilio.com/console
account_sid = "AC80b139ff5ff0f125d33f08486d5c2f93"
# Your Auth Token from twilio.com/console
auth_token = "your_auth_token"
client = Client(account_sid, auth_token)
message = client.messages.create(
to="+15558675309", # 接受短信的手机号,也就是注册界面验证过的那个自己的手机号,注意 写中国区号 +86
from_="+15017250604", # 发送短信的美国手机号 区号 +1
body="Hello from Python!")
print(message.sid)
更新一句:现在可以发送中文内容了
在服务器上训练深度学习模型,最后程序上加上这段代码,运行完成自动发短信通知模型效果,运行时间,舒服