PYTHON   64
tweet pic py
Guest on 25th August 2022 04:48:04 AM


  1. #!/usr/bin/env python
  2. from PIL import Image
  3. import StringIO
  4. from twython import Twython
  5.  
  6. tweetStr = "The robot tweeted this pic!"
  7. image = '/home/pi/time-lapse/pics/image0001.jpg'
  8.  
  9.  
  10. # your twitter consumer and access information goes here
  11. # note: these are garbage strings and won't work
  12. apiKey = '3jUZacO80oKslHnzj95QwuXBR' # put your API Key here
  13. apiSecret = 'DgtLS5AkuslR84CQBBjdPC84HGXg2RAnRVk8SdTTuJDYtgACSQ' # put API Secret here
  14. accessToken = '2901114905-OLi8mzAw83YTSveYub8FjcaObsebLlvm2fqBw0f' # access token here
  15. accessTokenSecret = 'SsHDfk9eptb8jStUQH6Sto7OnDWs9xzdbe3YhVzKkmuWY' #access token secret
  16.  
  17. photo = Image.open(image)
  18. image_io = StringIO.StringIO()
  19. photo.save(image_io, format='JPEG')
  20.  
  21. api = Twython(apiKey,apiSecret,accessToken,accessTokenSecret)
  22. api.update_status_with_media(media=image_io, status=tweetStr)
  23. #api.update_status(status=tweetStr)
  24.  
  25. print "Done\n"

Raw Paste

Login or Register to edit or fork this paste. It's free.