Skip to content

Instantly share code, notes, and snippets.

@BlogBlocks
Last active December 8, 2017 13:49
Show Gist options
  • Select an option

  • Save BlogBlocks/4a14d9dff41ac546185c5909b407f3a3 to your computer and use it in GitHub Desktop.

Select an option

Save BlogBlocks/4a14d9dff41ac546185c5909b407f3a3 to your computer and use it in GitHub Desktop.
# post image and tweet to Twitter
# USAGE: import Tpost
# Tpost.tpost(ImgPath,STR)
import sys
import twython
from twython import Twython
import Key
def tpost(ImgPath,STR):
CONSUMER_KEY = Key.twiter()[0]
CONSUMER_SECRET = Key.twiter()[1]
ACCESS_KEY = Key.twiter()[2]
ACCESS_SECRET = Key.twiter()[3]
twitter = Twython(CONSUMER_KEY, CONSUMER_SECRET, ACCESS_KEY,ACCESS_SECRET)
photo = open(ImgPath,'rb')
response = twitter.upload_media(media=photo)
twitter.update_status(status=STR, media_ids=[response['media_id']])
@BlogBlocks

Copy link
Copy Markdown
Author

Just what it sounds like a short Quick Tweet

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