Search api - image appended to tweet but media count = 0


I’m seeing tweets which appear to have images appended to the end of tweets while cutting off the tweet proper.

For example, tweet id 874697698053677056 gives me tweet text:

Warning: Do not throw pitch to Aaron Judge in strike zone. Literally no cold zone (blue), .550+ slugging in each se…

and a media count = 0.

Looking at that tweet in twitter on the web shows the full tweet (no characters cutoff) and an image.

Is this a known problem? Is there a timeline to fix it?



Where are you seeing “media count” - pulling the Tweet from statuses/show I can see it has both entities/media and extended_entities fields in the Tweet object.



This is the search query i made:

I’m not sure what you mean by statuses/show. Is that another way to get to that data? I’m also not familiar with extended_entities. I don’t see anything related to that in the json i’m getting back. Is there a search query i can make that will include this additional data?



The search API is problematic and rarely updated. Can you try adding the tweet_mode=extended parameter to your API query?


Adding that parameter gives me an exception:

The remote server returned an error: (401) Unauthorized.




Were you suggesting to do another query for each tweet using tweet_mode=extended? That would seem somewhat impractical for my search purposes because of the potentially large number of tweets a search might give me.

Are there plans to update the search api? If not, is there another way I should approach this? Basically, i’m trying to make standard twitter searches based on hashtags, accounts, words or location.



You should not need to do that - it should work with the search endpoint.

I just tried:

$ twurl "/1.1/search/tweets.json?q=-RT%20from:andypiper&tweet_mode=extended&result_type=recent&count=20"

This successfully returns both extended and normal (compatibility) mode Tweets.

The search query here is -RT from:andypiper … note that per the documentation you should not include the leading @ on a username. There is no exclude:replies parameter in the search syntax on that API endpoint.


I still get a “The remote server returned an error: (401) Unauthorized.” with the query you suggested.



That’s strange - how are you invoking the API? Are you URL encoding the request? twurl takes care of most of that (and escaping parameters) for me.


My code is a windows .exe written in .net c#. I’m not actually using any twitter-based libraries. Just stock .net http code.


OK. I’ll try to put something together using Tweetinvi and Visual Studio Code when I can to see if I can reproduce this - if you’re able to share any source code that may help. Given that this works in twurl I strongly suspect there is an encoding issue with the parameters somewhere here. I may not be able to dive too deeply into this myself for a few days :confused:


I’ll work on a small code sample I can share. Thanks.



I may have got it working. I switched the query from “&tweet_mode=extended&result_type=recent” to “&result_type=recent&tweet_mode=extended” and no more errors.

It looks like the parameter order matters.



Parameter order for creating the OAuth signature but not the request itself. See #2 of collecting paramters.