Consider a call to retrieve a Twitter user's list of favorites using abraham/twitteroauth PHP library:
https://api.twitter.com/1.1/favorites/list.json
Given the following parameters:
$params = array(
'screen_name' => $screenName,
'count' => $count,
'include_entities' => true,
);
Whereas all requested tweets actually show/embed a photo on the Twitter site, the related media
fields expected to be found within the entities
parent fields are not always present in the API response.
Here's a tweet whose response include the field, and another one whose response does NOT include it. You'll found respective JSON
responses in this Gist: https://gist.github.com/davidloubere/8331a2b523772d99c669e1e720aa4afc
Does someone have an explanation for this?
This happens because recently Twitter announced REST API changes that introduced two Tweets types:
Classic Tweet
- A Tweet object where the total length of the textcontent does not exceed 140 characters
Extended Tweet
- A Tweet object which includes hidden entities (e.g. leading @mentions and trailing attachment) and where thetext content exceeds 140 characters in length.
They also introduced
Compatibility
mode which is default when you work with Twitter REST API. There is alsoExtended
which you should set explicitly.Citate from the documentation at https://dev.twitter.com/overview/api/upcoming-changes-to-tweets:
So, the first Tweet is
Classic
, and the second isExtended
that gets truncated when you fetch it inCompatibility mode
. You can get its full version by settingtweet_mode=extended
in your Twitter REST API call.