Ekaterina1234
Ekaterina1234

Reputation: 410

Can't use Twilio with python

I used the code from the Twilio website to send a text message using python. I used real values, that I obtained during registration in the actual code. There aren't any XXXXXX in my program.

I removed the {{}} too. the code's still not working.

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)

This is the error I'm getting. What does this mean? Thanks!

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

Upvotes: 0

Views: 226

Answers (1)

OneCricketeer
OneCricketeer

Reputation: 192023

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

This does not mean place the value in the {{ }}. It means replace that entire string with your value.

Upvotes: 4

Related Questions