When querying for tweets sometimes images returned in the tweet are 404.

here is an example
https://api.twitter.com/2/tweets/:id?tweet.fields=attachments,author_id,conversation_id,created_at,id,referenced_tweets,public_metrics,entities&media.fields=duration_ms,height,media_key,preview_image_url,type,url,width,public_metrics,variants

example id: 1605234251263139840

https://pbs.twimg.com/news_img/1605234267906195458/Y-v93Z1c?format=jpg&name=orig

Should I also be comparing against media key and if not defined ignore the value.

Oh, the expanded url metadata was always a bit flaky - these images are meant to be cached from the website card, so i think you can still get them from the original url in the twitter:image meta tag: <meta property="twitter:image" content="https://there.oughta.be/assets/images/2022-12-20/youtube.jpg" /> on There oughta be a Game Boy capture cartridge.

1 Like