Skip to content

Instantly share code, notes, and snippets.

@Thinged
Last active May 26, 2017 20:19
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 Thinged/fddcb45f44ecf25d3c3341fcb7d64f8a to your computer and use it in GitHub Desktop.
Save Thinged/fddcb45f44ecf25d3c3341fcb7d64f8a to your computer and use it in GitHub Desktop.
Script for texting yourself a photo using your Raspberry Pi, Twilio, Cloudinary and Thinged.io
import subprocess
from twilio.rest import Client
import cloudinary
import cloudinary.uploader
import cloudinary.api
# put your own credentials here
twilio_account_sid = ""
twilio_auth_token = ""
twilio_client = Client(twilio_account_sid, twilio_auth_token)
twilio_from_number = ""
cloudinary_cloud_name = ""
cloudinary_api_key = ""
cloudinary_api_secret = "-"
cloudinary.config(cloud_name = cloudinary_cloud_name, api_key = cloudinary_api_key , api_secret = cloudinary_api_secret)
phone_number = ""
message = "Hello from Thinged.io"
def take_photo(name):
take_photo_command = 'raspistill -v -o ' + name
process = subprocess.Popen(take_photo_command, shell=True, stdout=subprocess.PIPE)
process.wait()
def upload_photo_to_cloudinary(file_name):
response = cloudinary.uploader.upload(file_name,tags="rpi")
return response['url']
def send_mms(to, message, media_url):
twilio_client.messages.create(
to=to,
from_=twilio_from_number,
body=message,
media_url=media_url)
if __name__ == '__main__':
photo_name = 'gears_big_400.png'
photo_location = take_photo(photo_name)
public_url = upload_photo_to_cloudinary(photo_name)
send_mms(phone_number, message, public_url)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment