Practically exactly what the title says. I want to tweet status with GIF in it, but I also want it to be automatically generated every time. The thing is I get just the URL, so is there any way to post just with the URL, or do I have to download it, if so could you help me with a way to autamtically download, tweet and ideally delete the Gif. I tried something like this, but it returns FileNotFoundError: [Errno 2] No such file or directory
:
import tweepy
auth = tweepy.OAuthHandler("N8IPuyAGAJumrJXXXXXXXXNt2", "WDW512XtqMlkpb3fES2WjjrqbpfcD3zsw80xSqXXXXXXXXXXXy")
auth.set_access_token("1536798202967601153-3s6XXXXXXXXXXXXXXXXXrZK9cHE3nO", "myVbx1FgUxyXXXXXXXXXXXXXXXXXXXXaFoWGJvKR19aCr")
api = tweepy.API(auth)
url = "https://giphy.com/gifs/WJjLyXCVvro2I"
message = "hihihihuhihi"
api.update_status_with_media(message, url)
I managed to solve it by downloading the gif, then posting the tweet and then removing the gif. First I had to get different url for the gif from giphy
api_response.data[x].images.original.url
Then I used urllib request to download it
from urllib import request
...
with open("test.gif", "wb") as f:
f.write(requests.get(url).content)
and then I just posted the tweet and deleted the GIF
import os
...
api.update_status_with_media(message, "test.gif")
os.remove("test.gif")
Sadly I didn’t figure out how to post only with the link.