我有這個小腳本上個月如何使用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