Running Our Code

Programming Foundations with Python >> Lessons >> Use Classes: Send Text >> Running Our Code

In order to get this code to pass, some additional edits not mentioned in the video lesson need to be made that stem from an updated Twilio page. Here is an example of the before and after:

Before Edits:

from twilio.rest import TwilioRestClient

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

client = TwilioRestClient(account_sid, auth_token)

message = client.messages.create(body="Hello from Python",
    to="+12345678901",    # Replace with your phone number
    from_="+12345678901") # Replace with your Twilio number

print(message.sid)

After Edits:

from twilio.rest import TwilioRestClient

account_sid = "account_sid" # Your Account SID from www.twilio.com/console
auth_token  = "auth_token"  # Your Auth Token from www.twilio.com/console

client = TwilioRestClient(account_sid, auth_token)

message = client.messages.create(body="Hello from Python",
    to="+12345678901",    # Replace with your phone number
    from_="+12345678901") # Replace with your Twilio number

print message.sid

Note that your account_sid and auth_token should be replaced by a long combo of letters and numbers copy pasted from your Twilio account, and both phone numbers should be replaced with your own phone number and the phone number given to you by Twilio.

Advertisements

Author: ajoannaproject

Studying Udacity's Full Stack Web Developer program and passing on my improvements, hints, hacks, and updates to other students via ajoannaproject.wordpress.com.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s