Getting statuses on Twitter via REST API doesn't always return media URLs
Asked Answered
O

1

5

I can't seem to get the embedded URL in a status, for example, in id=780804331608109057 -

https://twitter.com/i/web/status/780804331608109057

When I retrieve this via GET /statuses/:id, with include_entities set to true, the response looks like this:

"text":"Here\u2019s WSJ \"An Underwhelming Trump-Clinton Debate\u201d trying to spin this as something other than a Clinton triumph\u2026 https:\/\/t.co\/dpkmphGI8k", "truncated":true, "entities": {"hashtags":[],"symbols":[],"user_mentions":[],"urls":
[{"url":"https:\/\/t.co\/dpkmphGI8k", "expanded_url":"https:\/\/twitter.com\/i\/web\/status\/780804331608109057", "display_url":"twitter.com\/i\/web\/status\/7\u2026","indices":[114,137]}]}, "source":"\u003ca href=\"https:\/\/about.twitter.com\/products\/tweetdeck\"rel=\"nofollow\"\u003eTweetDeck\u003c\/a\u003e",....

When viewed on my web client, the status instead displays the link to WSJ (referred through t.co) What I would like is one or both of these URLs to show up in my API response:

  1. https://pbs.twimg.com/media/CtX5Sz8WIAAm4tq.jpg
  2. what would be the short URL that looks like "t.co" followed by "/HJs4kbmTKz" (I have to break this up so SO doesn't complain.)

What am I doing wrong here?

Onomatopoeia answered 27/9, 2016 at 17:5 Comment(0)
O
10

The incredibly fast response from a staffer on the TwitterCommunity website was most gratifying:

You need to use tweet_mode=extended for the new longer Tweet format.

Ref: https://twittercommunity.com/t/missing-media-property-in-entities/70388/4

A search on this new parameter yields the appropriate documentation on dev.twitter.com - more documentation links on this mode probably exist out there. The most significant change appears to be that the key text is no longer used in non-compatibility mode - that's where the status text is, and unless you turn on compatibility mode, you have to now use the key full_text

https://dev.twitter.com/overview/api/upcoming-changes-to-tweets

Onomatopoeia answered 27/9, 2016 at 18:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.