2016-06-10 43 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 

這並不意味着發生在{{ }}價值。這意味着用你的價值取代整個字符串。