【发布时间】:2018-02-19 10:47:44
【问题描述】:
我使用的是 Windows 10,我想使用 twilio API,所以首先通过终端安装了 twilio 并且安装成功,然后检查一切是否正常,我运行此代码:
import twilio
print twilio.__version__
输出是: 5.7.0
现在我想向我的手机发送消息,我注册并获取我的 account_sid、auth_token、twilio 号码并在我想向其发送消息的手机号码中注册,我在替换我的 account_sid 后尝试运行此代码,auth_token , twilio 号码并在我的电话号码中注册但它给出了例外这是代码:
from twilio.rest import TwilioRestClient
import twilio
print twilio.__version__
# Your Account SID from twilio.com/console
account_sid = "AC6791725bc93116fbd42b4cd477996f7d"
# Your Auth Token from twilio.com/console
auth_token = "30ed212f6a2bbc05d103b67426b8509a"
client = TwilioRestClient(account_sid, auth_token)
message = client.sms.messages.create(
body="Sent from your Twilio trial account - hello from python",
to="my number phone goes here",
from_="+14695356845" )
print message.sid
运行时错误:
Traceback (most recent call last):
File "C:/Users/Black_Swan/PycharmProjects/omac1/send message.py", line 14, in <module>
from_="+14695356845" )
File "C:\Python27\lib\site-packages\twilio\rest\resources\sms_messages.py", line 167, in create
return self.create_instance(kwargs)
File "C:\Python27\lib\site-packages\twilio\rest\resources\base.py", line 365, in create_instance
data=transform_params(body))
File "C:\Python27\lib\site-packages\twilio\rest\resources\base.py", line 200, in request
resp = make_twilio_request(method, uri, auth=self.auth, **kwargs)
File "C:\Python27\lib\site-packages\twilio\rest\resources\base.py", line 164, in make_twilio_request
uri=resp.url, msg=message, code=code)
twilio.rest.exceptions.TwilioRestException: HTTP 451 error: IP Address: 5.0.217.104
任何帮助我做错了什么?
【问题讨论】: