https://github.com/sferik/t/blob/7f1fcac61047dcb703e9519c837...
this is because the OP's own twitter ruby gem can do that, this CLI app is basically a front end for the ruby gem
client.update_with_media("I'm tweeting with @gem!", File.new("/path/to/media.png"))
from requests_oauthlib import OAuth1Session import json keys = json.loads(open(keyfile).read()) # {"TWITTER_CONSUMER_KEY": "blah_blah_blah", # "TWITTER_CONSUMER_SECRET": "blah_blah_blah", # "TWITTER_ACCESS_TOKEN": "blah_blah_blah", # "TWITTER_ACCESS_TOKEN_SECRET": "blah_blah_blah",} def twitter(): return OAuth1Session(keys['TWITTER_CONSUMER_KEY'], client_secret=keys['TWITTER_CONSUMER_SECRET'], resource_owner_key=keys['TWITTER_ACCESS_TOKEN'], resource_owner_secret=keys['TWITTER_ACCESS_TOKEN_SECRET']) def tweet(status, reply_to=None): endpoint = 'https://api.twitter.com/1.1/statuses/update.json' data = {'status': status} r = twitter().post(endpoint, data=data) return r.status_code def tweet_with_image(status, imgfile, reply_to=None): endpoint = 'https://api.twitter.com/1.1/statuses/update_with_media.json' data = {'status': status} if reply_to is not None: data.update({'in_reply_to_status_id': reply_to}) r = twitter().post(endpoint, data=data, files={'media[]': open(imgfile, 'rb').read()}) return r.status_code