I am trying to make a Twitter bot with tweepy. It’s actually my first twitter BOT, I’m kinda new to it.
I have a list of medias containing the path of each image I need to send.
I am able to send tweets with text
Or sending tweets with one single media
api.update_with_media(filename, status="some text with media")
But I need to send many images with my tweet.
I heard that I need to upload my files first but I don’t know how to integrate them in the tweet.
Or maybe there is another way of doing it ?
In case you want to upload multiple images, you can use Twitter API’s
media/upload via Tweepy’s
This method returns a response object containing
media_id and you can attach multiple
So the code you may want to write is like this:
# Upload images and get media_ids
filenames = ['1.png', '2.png', ...]
media_ids = 
for filename in filenames:
res = api.media_upload(filename)
# Tweet with multiple images
api.update_status(status="many images!✨", media_ids=media_ids)