我有这个小脚本上个月如何使用Twython将图像发布到Twitter?
from twython import Twython
import glob
import random
app_key = "XXX"
app_secret = "XXX"
oauth_token = "XXX"
oauth_token_secret = "XXX"
twitter = Twython(app_key, app_secret, oauth_token, oauth_token_secret)
def RandomImageTwitt(folder):
#Takes the folder where your images are as the input
images = glob.glob(folder + "*")
image_open = open(images[random.randint(0,len(images))-1])
twitter.update_status_with_media(media=image_open)
RandomImageTwitt("/home/XXX/.reddit-twitter-image/XXX/")
工作完美但现在Twitter已经弃用此方法。 Twython告诉我应该使用Twython.upload_media,但我找不到任何有关它的使用的文档。即使Twython官方网站仍然列出了update_status_with_media的例子。
任何人都知道如何去做或者在哪里找到一些例子/信息?
谢谢!最后,我换了包装纸,然后用tweepy去了。在我看来,它更简单。你可以在github上查看代码:https://github.com/joaquinlpereyra/ImageTwitterBot/blob/master/ImageTwitterBot.py – joaquinlpereyra 2014-12-03 15:15:55
你可以在这里找到文档:https://twython.readthedocs.org/en/latest/api。 html – Txugo 2014-12-13 00:40:14