5

I understand you can get the specific url of a tweet using the Twitter API by creating a url like this

https://twitter.com/username/status/tweet-id

However, is it possible to get an image of a tweet? I can get media images, but those are just images that people posted in the tweet. I want to know if it is possible to get an image of the tweet itself.

applecrusher
  • 5,508
  • 5
  • 39
  • 89

4 Answers4

4

Twitter's API includes the ability to do this with oembed.

https://dev.twitter.com/rest/reference/get/statuses/oembed

applecrusher
  • 5,508
  • 5
  • 39
  • 89
  • Nice info. But this only gets the oEmbed (HTML), not an image. I've tried setting `widget_type=photo` but no effect. – Hendy Irawan Dec 07 '16 at 05:24
  • 1
    I don't think there is any way to get a true image, only just the html. But if you have the html of the tweet, you could use a library like HTML2Canvas see link http://stackoverflow.com/questions/10721884/render-html-to-an-image to convert that HTML to the image you want. Make sure you include the CSS in your html as well. Good Luck with your endeavor! – applecrusher Dec 07 '16 at 06:46
  • Any solution for this – Jamsheer Dec 16 '16 at 12:02
  • Take the html and make it an image is really the only thing I can think of at this point but I haven't worked on this project in some time. – applecrusher Dec 17 '16 at 17:46
0

Fast forward to 2023 - none of the one above seems to be available anymore.

This library worked flawlessly for me. It is not an web API but works well and has good options: https://github.com/Xacnio/tweetcapture

palamunder
  • 2,555
  • 1
  • 19
  • 20
-1

You can now get images or screenshots of tweets using the @aissistant handle on twitter.

Retweet any tweet with the comment "@aissistant #image" to get an image.
Retweet any tweet with the comment "@aissistant #screenshot" to get a screenshot.

For other options like converting to memes and jokes check out the handle.

Full disclosure: I am creator of the bot behind the handle.

NVM
  • 5,442
  • 4
  • 41
  • 61