Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Twitter stream - location AND keywords

I am using the 'Twitter4j' library and I am just wondering if it is at all possible to return tweets within a location AND contain a certain keyword. I notice that on the official Twitter documentation it mentions this:

Bounding boxes are logical ORs. A locations parameter may be combined with track parameters, but note that all terms are logically ORd, so the query string track=twitter&locations=-122.75,36.8,-121.75,37.8 would match any tweets containing the term Twitter (even non-geo tweets) OR coming from the San Francisco area.

Which is unfortunate as it is not what I need, it's returning way too many tweets. Any idea on how I could get around this or is there something I'm missing in the library that could allow me to do it?

Library javadoc: http://twitter4j.org/en/javadoc/twitter4j/FilterQuery.html#locations

At the moment I have my filter code like this twitter.filter(new FilterQuery().locations(sydney).track(keywords));

and have also tried each on its own line: twitter.filter(new FilterQuery().locations(sydney).track(keywords));

twitter.filter(new FilterQuery().track(keywords));

like image 729
ponens Avatar asked Nov 14 '22 14:11

ponens


1 Answers

Unfortunately, you are reading the documents correctly. I don't know enough about twitter4j to say if there's a method contained somewhere that will handle this for you more easily, but you can always just use a simple string comparison to see if your search terms are included in the tweet.

like image 99
muffinista Avatar answered Dec 26 '22 14:12

muffinista