Skip to content

Instantly share code, notes, and snippets.

@mainframed
Created March 9, 2019 21:24
Show Gist options
  • Save mainframed/70b43168ff94ba70448e8d9161a1020f to your computer and use it in GitHub Desktop.
Save mainframed/70b43168ff94ba70448e8d9161a1020f to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import tweepy
import sys
# argument 1 is the tweet, argument 2 is the path to the image
def get_api(cfg):
auth = tweepy.OAuthHandler(cfg['consumer_key'], cfg['consumer_secret'])
auth.set_access_token(cfg['access_token'], cfg['access_token_secret'])
return tweepy.API(auth)
def main():
cfg = {
"consumer_key" : "",
"consumer_secret" : "",
"access_token" : "",
"access_token_secret" : ""
}
api = get_api(cfg)
tweet = sys.argv[1]
#status = api.update_status(status=tweet)
imagePath = sys.argv[2]
status = api.update_with_media(imagePath, tweet)
#print status
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment