Skip to content

Instantly share code, notes, and snippets.

@erinxocon
Created June 6, 2017 00:37
Show Gist options
  • Save erinxocon/cac8d321938c9ae6a913b77beec999f8 to your computer and use it in GitHub Desktop.
Save erinxocon/cac8d321938c9ae6a913b77beec999f8 to your computer and use it in GitHub Desktop.
from twilio.rest import Client
import socket
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.connect(("8.8.8.8", 80))
ip = s.getsockname()[0]
s.close()
# Your Account SID from twilio.com/console
account_sid = 'YOUR_ACCOUNT_SID'
# Your Auth Token from twilio.com/console
auth_token = 'YOUR AUTH TOKEN'
client = Client(account_sid, auth_token)
message = client.messages.create(
to='+17034890215',
from_='+19097666394',
body='Uh oh! Looks like the raspberry pi had to reboot, your current IP address is {0}. Please adjust your app config as needed!'.format(ip))
print(message.sid)
@erinxocon
Copy link
Author

add this to your rc.local or crontab file for use at startup!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment