Stathis G.
Stathis G.

Reputation: 135

Twitter Stream api filter by location AND track

I'm using the following line in order to get geolocated tweets that contain a certain keyword. (I'm using the word Madonna)

https://stream.twitter.com/1.1/statuses/filter.json?track=Madonna&locations=-180,-90,180,90

My problem is that result is not consisted by geolocated tweets that contain the keyword Madonna, but is consisted by geolocated tweets in general.

Any help on what I'm doing wrong here?

Upvotes: 4

Views: 4194

Answers (2)

Pat Marx
Pat Marx

Reputation: 339

Another, somewhat hack-y solution to this, is you can have a track key work that would never match, such as "dkghaskldfnascjkawenaf", and add a location bounding box.

The API does an OR relationship between tracking and location, you'll only receive tweets from within (or very nearby) the bounding box

Upvotes: 0

afschr
afschr

Reputation: 556

  1. "-180,-90,180,90" - it is worldwide location;

  2. Currently for use "AND" instead of "OR" in Twitter stream API you need make request like this: https://stream.twitter.com/1.1/statuses/filter.json?locations=-74,40,-73,41 and filtered results by "Madonna" inside your app after. Unfortunatly, I can not find another way for today;

  3. Filtering by locations can contain:

If coordinates is empty but place is populated, the region defined in place is checked for intersection against the locations bounding box. Any overlap will match.

Upvotes: 3

Related Questions