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


#1

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… https://t.co/YaUh8EtMSr

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?

gh


#2

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.


#3

Andy,

This is the search query i made:

https://api.twitter.com/1.1/search/tweets.json?q=-RT%20from%3A%40ktsharp%20exclude%3Areplies&result_type=recent&count=20

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?

gh


#4

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


#5

Adding that parameter gives me an exception:

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

gh


#6

Andy,

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.

gh


#7

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.


#8

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

gh


#9

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.


#10

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


#11

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:


#12

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


#13

Andy,

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.

gh


#14

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