ho avuto questo piccolo script perfettamente funzionante per il mese scorsoCome postare l'immagine su Twitter con Twython?
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/")
Ma ora Twitter ha deprecato questo metodo. Twython mi dice che dovrei usare Twython.upload_media, ma non riesco a trovare alcun documento sul suo utilizzo. Anche i siti ufficiali di Twython presentano ancora un esempio con update_status_with_media.
Qualcuno sa come farlo o dove trovare alcuni esempi/informazioni?
Grazie! Alla fine, cambiai i wrapers e andai con i tweepy. È, a mio parere, più semplice. Puoi controllare il codice su github: https://github.com/joaquinlpereyra/ImageTwitterBot/blob/master/ImageTwitterBot.py – joaquinlpereyra
puoi trovare la documentazione qui: https: //twython.readthedocs.org/en/latest/api. html – Txugo