Skip to content

Instantly share code, notes, and snippets.

@SeanOC
Created July 27, 2010 18:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SeanOC/492617 to your computer and use it in GitHub Desktop.
Save SeanOC/492617 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import twilio
import time
# Setup twilio info
API_VERSION = '2008-08-01'
ACCOUNT_SID = 'REPLACE_ME'
ACCOUNT_TOKEN = 'REPLACE_ME'
account = twilio.Account(ACCOUNT_SID, ACCOUNT_TOKEN)
FROM_NUMBER = '(555) 555-5555'
TO_NUMBER = '(555) 555-5555'
# Wait for something to happen
happened = False
while not happened:
happened = test_that_something_happened()
if not happened:
time.sleep(30)
# When it happens send a text message
if happened:
d = {
'From': FROM_NUMBER,
'To': TO_NUMBER,
'Body': 'It happened!',
}
account.request('/%s/Accounts/%s/SMS/Messages' % (API_VERSION, ACCOUNT_SID), 'POST', d)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment