Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Twilio Best Practices
  • Toc
  • feedback
Twilio Best Practices

Twilio Best Practices

By : Rogers
4.5 (4)
close
Twilio Best Practices

Twilio Best Practices

4.5 (4)
By: Rogers

Overview of this book

If you have experience with at least one programming language and are looking to integrate Twilio into your applications, then this book is for you.
Table of Contents (10 chapters)
close
9
Index

Python


We can install the Twilio package for Python using pip, which is Python's standard package manager.

Note

If you don't have pip installed, follow the instructions at https://pip.pypa.io/en/latest/installing.html to install it.

To install the package, simply run the pip install twilio command.

In your code, you'll just need to import the library, and then you can instantiate the client (client.py) like this:

from twilio.rest import TwilioRestClient
import os
account_sid = os.environ.get('TWILIO_ACCOUNT_SID')
auth_token = os.environ.get('TWILIO_AUTH_TOKEN')
client = TwilioRestClient(account_sid, auth_token)

Once you've set up your client, the syntax for sending an SMS is very similar to the one used in other examples, somewhere between the PHP and Ruby implementation, making use of keyword arguments (send_sms.py):

message = client.messages.create(to="+441290211999", from_="+441708300116", body="This is an SMS message.")

Here, our from_ parameter includes an underscore at the end because from...

bookmark search playlist font-size

Change the font size

margin-width

Change margin width

day-mode

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Delete Bookmark

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete