我的代码:
from twilio.rest import Client
# Find these values at https://twilio.com/user/account
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
auth_token = "your_auth_token"
client = Client(account_sid, auth_token)
client.api.account.messages.create(
to="+#############",
from_="+###########",
body="Hello there!")
我得到的错误:
Traceback (most recent call last):
File "C:\Users\Keshavarz\Desktop\twilio1.py", line 14, in <module>
body='Hello there!'
File "C:\Users\Keshavarz\AppData\Local\Programs\Python\Python36-32\lib\site-packages\twilio\rest\api\v2010\account\message\__init__.py", line 92, in create
data=data,
File "C:\Users\Keshavarz\AppData\Local\Programs\Python\Python36-32\lib\site-packages\twilio\base\version.py", line 209, in create
raise self.exception(method, uri, response, 'Unable to create record')
twilio.base.exceptions.TwilioRestException:
[31m[49mHTTP Error[0m [37m[49mYour request was:[0m
[36m[49mPOST /Accounts/AC2b7b52ba2fc52a5eebf2c060257f7a7c/Messages.json[0m
[37m[49mTwilio returned the following information:[0m
[34m[49mUnable to create record[0m
[37m[49mMore information may be available here:[0m
[34m[49mhttps://www.twilio.com/docs/errors/451[0m
我满足所有制作SID和身份验证令牌based on this link但我无法向手机发送任何短信#
答案 0 :(得分:0)
Twilio开发者传道者在这里。
该响应中有一个URL可以帮助解释发生了什么。可悲的是,它似乎在日志中有些乱码。
我建议您抓住错误并尝试以其他方式打印。试试这个,看看结果如何:
client = Client(account_sid, auth_token)
try:
client.api.account.messages.create(
to="+#############",
from_="+###########",
body="Hello there!")
except TwilioRestException as ex:
print(ex)