Created
May 13, 2012 20:19
-
-
Save michaelhelmick/2690021 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
from requests.auth import OAuth1 | |
url = 'https://upload.twitter.com/1/statuses/update_with_media.json' | |
auth = OAuth1(app_key, app_secret, | |
oauth_token, oauth_secret, | |
signature_type='auth_header') | |
data = {'status': 'Testing status with images'} | |
the_file = '/path/to/file/on/my/computer/image.jpg' | |
file_ = {'media': (the_file, open(the_file, 'rb'))} | |
print requests.post(url, data=data, files=file_, auth=auth) | |
# returns a <Response[401]> | |
''' | |
If I set data={} it returns a <Response[200]> and posts the status with just a link to the image | |
(https://twitter.com/#!/kevinkrpstomp/status/201767758894071811) | |
''' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment