Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/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
You can’t perform that action at this time.