Image media missing from get request of certain tweets

restapi
media
php

#1

For some reason when I perform a get request images aren’t included with some tweets. Below is the line I’m using to get the tweets. Also, below is an ID of a working tweet and a non working tweet. The tweets are back to back in my feed and after comparing the two objects returned, I can’t see anything obvious other than the fact that one tweet object includes “media” under entities and extended_entities while the other tweet object doesn’t.

FYI: I get the same result if I call the tweets by ID using GET statuses/show/:id

API calls:

$get_tweets_arr = $twitter_obj->get(‘statuses/user_timeline’, [‘count’ => 30, ‘include_rts’ => true, ‘tweet_mode’ => ‘extended’]);

Not working tweet ID: 887449299218509826
working ID: 887466315635716096

Any help is appreciated! Thanks!


#2

I’m not able to reproduce this - using twurl I just fetched both of those Tweet IDs and both have media and extended_entities values as expected (neither of them are extended Tweets).


#3

Thanks Andy. I’m using twitteroauth. I should have mentioned that in my original post. I would like to stick with twitteroauth but may have to switch if it’s the issue.


#4

I’ve not heard of that issue with TwitterOAuth before - @abraham is usually very good with this kind of thing so he may be able to help with any clues here.


#5

Agreed, it’s a great product. I’ll reach out to @abraham and see if he can help.


#6

Andy,

I just want to confirm that for the above ID you’re showing a media object when you fetch that ID. When I use the online API Console and I do a GET “https://api.twitter.com/1.1/statuses/show/887449299218509826.json”, the JSON that is returned has no mention of media. Entities is present (NOT extended_entities) and media is not present. This means that it’s not a twitteroauth thing for me for sure. I’m at a loss here.


#7

The online API console is unsupported and will be retired soon. I do not recommend using it.

Using twurl, Postman, and my own Twitter Kit-based iOS API client, I can retrieve that Tweet ID and I see retweeted_status.entities.media and retweeted_status.extended_entities as expected.


#8

Hi Andy,

I setup twurl, ran % twurl /1.1/statuses/show/887449299218509826

No Media object… Could it be a network issue with the network from which the request originates?

Response:
{“created_at”:“Tue Jul 18 23:09:35 +0000 2017”,“id”:887449299218509826,“id_str”:“887449299218509826”,“text”:“RT @RollTideKY: Spent the day seeing some of the facilities at @bamaengineering. This @UAEcoCar3 is fantastic. #RollTide #WhereLegendsAreMa\u2026”,“truncated”:false,“entities”:{“hashtags”:[{“text”:“RollTide”,“indices”:[111,120]}],“symbols”:[],“user_mentions”:[{“screen_name”:“RollTideKY”,“name”:“Alana Karl”,“id”:1702542878,“id_str”:“1702542878”,“indices”:[3,14]},{“screen_name”:“bamaengineering”,“name”:“Alabama Engineering”,“id”:492533592,“id_str”:“492533592”,“indices”:[63,79]},{“screen_name”:“UAEcoCar3”,“name”:“UA EcoCAR 3”,“id”:2801965035,“id_str”:“2801965035”,“indices”:[86,96]}],“urls”:[]},“source”:"\u003ca href=“http://twitter.com” rel=“nofollow”\u003eTwitter Web Client\u003c/a\u003e",“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”:{“id”:492533592,“id_str”:“492533592”,“name”:“Alabama Engineering”,“screen_name”:“bamaengineering”,“location”:“Tuscaloosa, AL”,“description”:“One of the first five universities in the nation to offer engineering classes, the UA College of Engineering is student-centered in education and research.”,“url”:“http://t.co/W2NMpPLPig",“entities”:{“url”:{“urls”:[{“url”:“http://t.co/W2NMpPLPig”,“expanded_url”:“http://eng.ua.edu”,“display_url”:“eng.ua.edu”,“indices”:[0,22]}]},“description”:{“urls”:[]}},“protected”:false,“followers_count”:2617,“friends_count”:1179,“listed_count”:50,“created_at”:"Tue Feb 14 20:44:13 +0000 2012”,“favourites_count”:772,“utc_offset”:-18000,“time_zone”:“Central Time (US & Canada)”,“geo_enabled”:true,“verified”:false,“statuses_count”:3214,“lang”:“en”,“contributors_enabled”:false,“is_translator”:false,“is_translation_enabled”:false,“profile_background_color”:“090605”,“profile_background_image_url”:“http://pbs.twimg.com/profile_background_images/425882817/bamaengineering_bg.jpg",“profile_background_image_url_https”:“https://pbs.twimg.com/profile_background_images/425882817/bamaengineering_bg.jpg”,“profile_background_tile”:true,“profile_image_url”:“http://pbs.twimg.com/profile_images/728295485803532289/8LV4zkxT_normal.jpg”,“profile_image_url_https”:“https://pbs.twimg.com/profile_images/728295485803532289/8LV4zkxT_normal.jpg”,“profile_banner_url”:“https://pbs.twimg.com/profile_banners/492533592/1398434991”,“profile_link_color”:“730303”,“profile_sidebar_border_color”:“C0DEED”,“profile_sidebar_fill_color”:“DDEEF6”,“profile_text_color”:“333333”,“profile_use_background_image”:true,“has_extended_profile”:false,“default_profile”:false,“default_profile_image”:false,“following”:false,“follow_request_sent”:false,“notifications”:false,“translator_type”:“none”},“geo”:null,“coordinates”:null,“place”:null,“contributors”:null,“retweeted_status”:{“created_at”:"Tue Jul 18 23:07:07 +0000 2017”,“id”:887448679237517312,“id_str”:“887448679237517312”,“text”:“Spent the day seeing some of the facilities at @bamaengineering. This @UAEcoCar3 is fantastic. #RollTide\u2026 https://t.co/Z5FqclIXzN",“truncated”:true,“entities”:{“hashtags”:[{“text”:“RollTide”,“indices”:[95,104]}],“symbols”:[],“user_mentions”:[{“screen_name”:“bamaengineering”,“name”:"Alabama Engineering”,“id”:492533592,“id_str”:“492533592”,“indices”:[47,63]},{“screen_name”:“UAEcoCar3”,“name”:“UA EcoCAR 3”,“id”:2801965035,“id_str”:“2801965035”,“indices”:[70,80]}],“urls”:[{“url”:“https://t.co/Z5FqclIXzN",“expanded_url”:“https://twitter.com/i/web/status/887448679237517312”,“display_url”:“twitter.com/i/web/status/8\u2026”,“indices”:[106,129]}]},“source”:"\u003ca href=“http://twitter.com/download/iphone” rel=“nofollow”\u003eTwitter for iPhone\u003c/a\u003e”,“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”:{“id”:1702542878,“id_str”:“1702542878”,“name”:“Alana Karl”,“screen_name”:“RollTideKY”,“location”:“Louisville”,“description”:“Regional Recruiter for The University of Alabama based in Louisville, KY. #UA21 #RollTide”,“url”:“https://t.co/w4BiGsypOu",“entities”:{“url”:{“urls”:[{“url”:“https://t.co/w4BiGsypOu”,“expanded_url”:“http://gobama.ua.edu/recruiters/alanakarl/”,“display_url”:“gobama.ua.edu/recruiters/ala\u2026”,“indices”:[0,23]}]},“description”:{“urls”:[]}},“protected”:false,“followers_count”:233,“friends_count”:272,“listed_count”:3,“created_at”:"Mon Aug 26 17:50:52 +0000 2013”,“favourites_count”:144,“utc_offset”:-14400,“time_zone”:“Eastern Time (US & Canada)”,“geo_enabled”:false,“verified”:false,“statuses_count”:440,“lang”:“en”,“contributors_enabled”:false,“is_translator”:false,“is_translation_enabled”:false,“profile_background_color”:“000000”,“profile_background_image_url”:“http://abs.twimg.com/images/themes/theme1/bg.png",“profile_background_image_url_https”:“https://abs.twimg.com/images/themes/theme1/bg.png”,“profile_background_tile”:false,“profile_image_url”:“http://pbs.twimg.com/profile_images/742365696127078404/XLLbMme2_normal.jpg”,“profile_image_url_https”:“https://pbs.twimg.com/profile_images/742365696127078404/XLLbMme2_normal.jpg”,“profile_link_color”:“990000”,“profile_sidebar_border_color”:“000000”,“profile_sidebar_fill_color”:“000000”,“profile_text_color”:“000000”,“profile_use_background_image”:false,“has_extended_profile”:false,“default_profile”:false,“default_profile_image”:false,“following”:true,“follow_request_sent”:false,“notifications”:false,“translator_type”:“none”},“geo”:null,“coordinates”:null,“place”:null,“contributors”:null,“is_quote_status”:false,“retweet_count”:2,“favorite_count”:10,“favorited”:true,“retweeted”:true,“possibly_sensitive”:false,“possibly_sensitive_appealable”:false,“lang”:“en”},“is_quote_status”:false,“retweet_count”:2,“favorite_count”:0,“favorited”:true,“retweeted”:true,“lang”:"en”}


#9

Apologies, I misspoke when I said that is not an extended Tweet. Try again using tweet_mode=extended.


#10

Getting 887449299218509826 with tweet_mode=extended shows media under the retweeted_status tweet object in entities for me.


#11

@andypiper Thanks! When I use /1.1/statuses/show/887449299218509826 with tweet_mode=extended it works.

So to be more specific on my original question now, does tweet_mode=extended work with statuses/user_timeline? Is there an equivalent?


#12

I thought it should work with all of the endpoints that return Tweets, but I’m prepared to be mistaken. A workaround would be to look for the field truncated: true in the timeline Tweet object, and retrieve with statuses/show and extended mode if the Tweet is listed as an extended one.


#13

Thank you @andypiper and @abraham! I appreciate y’all!!!