Twilio

From Omnia
Jump to navigation Jump to search

Python

Twilio Docs - Python Install - https://www.twilio.com/docs/python/install

sudo pip install twilio

Send SMS:

from twilio.rest import TwilioRestClient
# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = ""
auth_token = ""
client = TwilioRestClient(account_sid, auth_token)
message = client.messages.create(body="Jenny please?! I love you <3",
        to="+14159352345", # Replace with your phone number
        from_="+14158141829") # Replace with your Twilio number
print message.sid

Exceptions thrown as:

try:
   ...
except twilio.TwilioRestException as e:
   # handle e
   print e