Skip to content

Instantly share code, notes, and snippets.

@michaelhelmick
Last active December 15, 2015 04:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michaelhelmick/5199754 to your computer and use it in GitHub Desktop.
Save michaelhelmick/5199754 to your computer and use it in GitHub Desktop.
import os
import requests
from requests_oauthlib import OAuth1
auth = OAuth1('*APP_KEY*', '*APP_SECRET*',
'*OAUTH_TOKEN*', '*OAUTH_TOKEN_SECRET*',
signature_type='auth_header')
file_ = open('/path/to/file/image.jpg', 'rb')
requests.post('https://api.twitter.com/1.1/statuses/update_with_media.json',
data={'status': 'Hey'},
files={'media': (os.path.basename(file_.name), file_)},
auth=auth)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment