首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Twilio - Python异常,同时发送SMS - Udacity教程

Twilio - Python异常,同时发送SMS - Udacity教程
EN

Stack Overflow用户
提问于 2016-05-17 17:26:16
回答 1查看 773关注 0票数 0

我学习了Udacity教程中的Twilio,并得到了如下异常:

代码语言:javascript
运行
复制
Traceback (most recent call last):
  File "/Users/kaushiksekar/Documents/Programs/Python/send_text.py", line 10, in <module>
    from_="+14066234282") # Replace with your Twilio number
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/twilio-6.3.dev0-py2.7.egg/twilio/rest/resources/messages.py", line 122, in create
    return self.create_instance(kwargs)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/twilio-6.3.dev0-py2.7.egg/twilio/rest/resources/base.py", line 365, in create_instance
    data=transform_params(body))
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/twilio-6.3.dev0-py2.7.egg/twilio/rest/resources/base.py", line 200, in request
    resp = make_twilio_request(method, uri, auth=self.auth, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/twilio-6.3.dev0-py2.7.egg/twilio/rest/resources/base.py", line 164, in make_twilio_request
    uri=resp.url, msg=message, code=code)
TwilioRestException: 
[31m[49mHTTP Error[0m [37m[49mYour request was:[0m

[36m[49mPOST https://api.twilio.com/2010-04-01/Accounts/{{ AC142b2a041b9695a2e7d73572cd7989b0 }}/Messages.json[0m

[37m[49mTwilio returned the following information:[0m

[34m[49m[0m

>>> 

代码:

代码语言:javascript
运行
复制
from twilio.rest import TwilioRestClient

account_sid = "{{ authorization sid copied correctly from the site }}" # Your Account SID from www.twilio.com/console
auth_token  = "{{  authorization token copied correctly from the site  }}"  # Your Auth Token from www.twilio.com/console

client = TwilioRestClient(account_sid, auth_token)

message = client.messages.create(body="Hey this is a Test SMS",
    to="+919551771607",    # Replace with your phone number
    from_="+14066234282") # Replace with your Twilio number

print(message.sid)

对这个问题有什么建议吗?

EN

Stack Overflow用户

回答已采纳

发布于 2016-05-19 03:59:41

哦,我忘了在定义account_sid和auth_token变量时移除大括号。拆下支架后,它就正常工作了。

修正代码:

代码语言:javascript
运行
复制
from twilio.rest import TwilioRestClient

    account_sid = " authorization sid copied correctly from the site " # Your Account SID from www.twilio.com/console
    auth_token  = "  authorization token copied correctly from the site "  # Your Auth Token from www.twilio.com/console

    client = TwilioRestClient(account_sid, auth_token)

    message = client.messages.create(body="Hey this is a Test SMS",
        to="+919551771607",    # Replace with your phone number
        from_="+14066234282") # Replace with your Twilio number

    print(message.sid)
票数 0
EN
查看全部 1 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/37282742

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档