- #!/usr/bin/env python
- from PIL import Image
- import StringIO
- from twython import Twython
- tweetStr = "The robot tweeted this pic!"
- image = '/home/pi/time-lapse/pics/image0001.jpg'
- # your twitter consumer and access information goes here
- # note: these are garbage strings and won't work
- apiKey = '3jUZacO80oKslHnzj95QwuXBR' # put your API Key here
- apiSecret = 'DgtLS5AkuslR84CQBBjdPC84HGXg2RAnRVk8SdTTuJDYtgACSQ' # put API Secret here
- accessToken = '2901114905-OLi8mzAw83YTSveYub8FjcaObsebLlvm2fqBw0f' # access token here
- accessTokenSecret = 'SsHDfk9eptb8jStUQH6Sto7OnDWs9xzdbe3YhVzKkmuWY' #access token secret
- photo = Image.open(image)
- image_io = StringIO.StringIO()
- photo.save(image_io, format='JPEG')
- api = Twython(apiKey,apiSecret,accessToken,accessTokenSecret)
- api.update_status_with_media(media=image_io, status=tweetStr)
- #api.update_status(status=tweetStr)
- print "Done\n"
Raw Paste