Twilio

From Omnia
Revision as of 15:30, 15 February 2015 by Kenneth (talk | contribs) (Created page with "== Python == Twilio Docs - Python Install - https://www.twilio.com/docs/python/install sudo pip install twilio Send SMS: <pre> from twilio.rest import TwilioRestClient # Y...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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