How can I add a multiple queries to my search method? I would use this in a servlet.
This is my code now:
private static void searchQuery(Twitter twitter) {
try {
Query query = new Query("test soccer");
QueryResult result;
do {
result = twitter.search(query);
List<Status> tweets = result.getTweets();
System.out.println("tweets: " + tweets.size());
for (Status tweet : tweets) {
System.out.println("@" + tweet.getUser().getScreenName() + " - " + tweet.getText());
}
} while ((query = result.nextQuery()) != null);
System.exit(0);
} catch (TwitterException te) {
te.printStackTrace();
System.out.println("Failed to search tweets: " + te.getMessage());
System.exit(-1);
}
}
Thanks for you help!
You can make queries just joining them into the Query object, just like this
Query query = new Query("(test soccer) OR (test basquet) OR (test tenis)");
But you must take care of the max length of the query because twitter can say you that the query is too complex to understand.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With