StreaminAPI Search with Coordinates - JsonObjectReceived fires but not MatchingTweetAndLocationReceived

May 28, 2014 at 3:20 PM
I have implemented a small test-application to collect tweets with Tracks and Location. As I will persist the data in a database I use the Event JsonObjectReceived .

What is the difference between JsonObjectReceived and MatchingTweetAndLocationReceived?

When I make a query with Tracks and Coordinates the Event JsonObjectReceived is fired but not the Event MatchingTweetAndLocationReceived.

Thanks in advance for answers.
May 28, 2014 at 9:02 PM

The reason is that Twitter does not allow to search for 2 type of parameters at the same time.
It means that when you add a track and a location twitter will send all the tweets that either the track parameter, the location parameter or both.

Consequently Tweetinvi provides 2 ways to use the FilteredStream, StartStreamMatchingAnyCondition which is the Twitter behavior or StartStreamMatchingAllConditions.
StartStreamMatchingAllConditions analyzes the value of the Tweet and verify that all the requirements of a filter are matched. It means that only a tweet matching both the track and location will be sent to the user.

The JsonObjectReceived is an event which goal is to send the result from Twitter as is. This is the StartStreamMatchingAnyCondition behavior.
Currently there is no event allowing to detect that a json response is matching all the conditions. Maybe this is what you want to do and I will consider adding this feature.

Please let me know if what I told you makes any sense.

May 30, 2014 at 9:26 AM

Thanks for the exact Explanation - great answer - great Project. Yes, I think it would be a nice feature to imlement methods like JsonMatchiingTweeetAndLocationReceived - because especially for the streamingapi it is common to persist the tweet in a database.