Media parameter is not returned via Twitter API

restapi
media

#1

When I am trying to pull in a twitter post that contains an image or a video via the API from an owned twitter account I do not get the media parameter.

Following is an example.

{
“created_at”: “Sun Jan 08 15:07:06 +0000 2017”,
“id”: 818111797169442800,
“id_str”: “818111797169442817”,
“text”: “Black never goes out of fashion! Channel your inner retro diva with our classic Ebony Black by Casting Créme Gloss… https://t.co/aEHgSUFLl8”,
“truncated”: true,
“entities”: {
“hashtags”: [],
“symbols”: [],
“user_mentions”: [],
“urls”: [
{
“url”: “https://t.co/aEHgSUFLl8”,
“expanded_url”: “https://twitter.com/i/web/status/818111797169442817”,
“display_url”: “twitter.com/i/web/status/8…”,
“indices”: [
116,
139
]
}
]
},
“source”: “Twitter Web Client”,
“in_reply_to_status_id”: null,
“in_reply_to_status_id_str”: null,
“in_reply_to_user_id”: null,
“in_reply_to_user_id_str”: null,
“in_reply_to_screen_name”: null,
“user”: {…},
“geo”: null,
“coordinates”: null,
“place”: null,
“contributors”: null,
“is_quote_status”: false,
“retweet_count”: 0,
“favorite_count”: 10,
“favorited”: false,
“retweeted”: false,
“possibly_sensitive”: false,
“possibly_sensitive_appealable”: false,
“lang”: “en”
}

For some posts I do receive the image. Following is an example of a post that I received the media parameter.

{
“created_at”: “Fri Jan 20 14:33:07 +0000 2017”,
“id”: 822451897663524900,
“id_str”: “822451897663524865”,
“text”: “Which one will be the Holiday #ColourOfTheYear? Vote for your favourite now! https://t.co/CndgAlRQCT”,
“truncated”: false,
“entities”: {
“hashtags”: [
{
“text”: “ColourOfTheYear”,
“indices”: [
30,
46
]
}
],
“symbols”: [],
“user_mentions”: [],
“urls”: [],
“media”: [
{
“id”: 822451841241731100,
“id_str”: “822451841241731075”,
“indices”: [
77,
100
],
“media_url”: “http://pbs.twimg.com/media/C2nvl5IUUAM-Jul.jpg”,
“media_url_https”: “https://pbs.twimg.com/media/C2nvl5IUUAM-Jul.jpg”,
“url”: “https://t.co/CndgAlRQCT”,
“display_url”: “pic.twitter.com/CndgAlRQCT”,
“expanded_url”: “https://twitter.com/LOrealParisIn/status/822451897663524865/photo/1”,
“type”: “photo”,
“sizes”: {
“medium”: {
“w”: 660,
“h”: 330,
“resize”: “fit”
},
“small”: {
“w”: 660,
“h”: 330,
“resize”: “fit”
},
“large”: {
“w”: 660,
“h”: 330,
“resize”: “fit”
},
“thumb”: {
“w”: 150,
“h”: 150,
“resize”: “crop”
}
}
}
]
},
“extended_entities”: {
“media”: [
{
“id”: 822451841241731100,
“id_str”: “822451841241731075”,
“indices”: [
77,
100
],
“media_url”: “http://pbs.twimg.com/media/C2nvl5IUUAM-Jul.jpg”,
“media_url_https”: “https://pbs.twimg.com/media/C2nvl5IUUAM-Jul.jpg”,
“url”: “https://t.co/CndgAlRQCT”,
“display_url”: “pic.twitter.com/CndgAlRQCT”,
“expanded_url”: “https://twitter.com/LOrealParisIn/status/822451897663524865/photo/1”,
“type”: “photo”,
“sizes”: {
“medium”: {
“w”: 660,
“h”: 330,
“resize”: “fit”
},
“small”: {
“w”: 660,
“h”: 330,
“resize”: “fit”
},
“large”: {
“w”: 660,
“h”: 330,
“resize”: “fit”
},
“thumb”: {
“w”: 150,
“h”: 150,
“resize”: “crop”
}
}
}
]
},
“source”: “Twitter Web Client”,
“in_reply_to_status_id”: null,
“in_reply_to_status_id_str”: null,
“in_reply_to_user_id”: null,
“in_reply_to_user_id_str”: null,
“in_reply_to_screen_name”: null,
“user”: {…},
“geo”: null,
“coordinates”: null,
“place”: null,
“contributors”: null,
“is_quote_status”: false,
“retweet_count”: 18,
“favorite_count”: 22,
“favorited”: false,
“retweeted”: false,
“possibly_sensitive”: false,
“possibly_sensitive_appealable”: false,
“lang”: “en”
}


#2

This shows that the Tweet is an extended Tweet.

If you retrieve this Tweet using the tweet_mode=extended parameter, you will see the associated media entities.


#3

Thank you for your reply. What is the difference between a truncated tweet and a non truncated tweet ?. Why are some tweets truncated ?


#4

Several months ago we started to roll out changes to enable some Tweets to carry more information by not counting some attachment URLs and replies in the body of the message. For compatibility, the default behaviour is to truncate such Tweets to the existing 140 character text body. Links and attachments may be “hidden” in such cases.