2016-06-10 95 views
0

我使用Twilio网站上的代码到send a text message using python。我使用了实际代码中注册时获得的实际值。我的程序中没有任何XXXXXX。不能使用Twilio和python

我也删除了{{}}。该代码仍然无法正常工作。

from twilio.rest import TwilioRestClient 

account_sid = "{{ AC3XXXXXXXXXXXXXXXXXXXXXXXXXXXXX }}" # Your Account SID from www.twilio.com/console 
auth_token = "{{ 04e4c31XXXXXXXXXXXXXXXXXXXXXXXXXX }}" # Your Auth Token from www.twilio.com/console 

client = TwilioRestClient(account_sid, auth_token) 

message = client.messages.create(body="Hello from python. ", 
    to="+447XXXXXXXXXX", # Replace with your phone number 
    from_="+4417XXXXXXXXXXX") # Replace with your Twilio number 

print(message.sid) 

这是我得到的错误。这是什么意思? 谢谢!

Traceback (most recent call last): 
    File "C:/Users/Pawel/Desktop/Courses/Udacity/Python/send_text.py", line 10, in <module> 
    from_="+441753254382") # Replace with your Twilio number 
    File "C:\Python27\lib\site-packages\twilio-6.3.dev0-py2.7.egg\twilio\rest\resources\messages.py", line 122, in create 
    return self.create_instance(kwargs) 
    File "C:\Python27\lib\site-packages\twilio-6.3.dev0-py2.7.egg\twilio\rest\resources\base.py", line 365, in create_instance 
    data=transform_params(body)) 
    File "C:\Python27\lib\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 "C:\Python27\lib\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/{{ AC3ea248ea5628ce024619440468334835 }}/Messages.json[0m 

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

[34m[49m[0m 
+0

你忘了删除第二个ACEeaXXXXX值吗? –

+0

无论如何,它看起来像你的终端无法显示这些消息的编码。这应该读取'HTTP错误:您的请求是:' –

回答

4
account_sid = "{{ account_sid }}" # Your Account SID from www.twilio.com/console 

这并不意味着发生在{{ }}价值。这意味着用你的价值取代整个字符串。