Last active
August 29, 2015 14:17
-
-
Save minimumnz/55293650c0187a9e7ed5 to your computer and use it in GitHub Desktop.
Embed an image with a tweet using Twitter API and Twython
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
from twython import Twython | |
import sys | |
import requests | |
import shutil | |
CONSUMER_KEY = '' | |
CONSUMER_SECRET = '' | |
OAUTH_TOKEN = '' | |
OAUTH_TOKEN_SECRET = '' | |
twyapi = Twython(CONSUMER_KEY,CONSUMER_SECRET,OAUTH_TOKEN,OAUTH_TOKEN_SECRET) | |
path = "/home/richard/project/image.jpg" | |
photo = open(path, 'rb') | |
media_uploaded = twyapi.upload_media(media=photo) | |
media_id = media_uploaded['media_id'] | |
response = twyapi.update_status(status=composed_tweet, media_ids=media_uploaded['media_id']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment