Skip to content

Instantly share code, notes, and snippets.

@komiya-atsushi
Created November 14, 2012 14:06
Show Gist options
  • Save komiya-atsushi/4072279 to your computer and use it in GitHub Desktop.
Save komiya-atsushi/4072279 to your computer and use it in GitHub Desktop.
#twitter4j QueryResult#nextQuery() always returns null
/*
* Reproducing code of TFJ-705 ( http://jira.twitter4j.org/browse/TFJ-705 )
*/
import twitter4j.Query;
import twitter4j.QueryResult;
import twitter4j.Twitter;
import twitter4j.TwitterException;
import twitter4j.TwitterFactory;
public class QueryResultNextQueryDemo {
public static void main(String[] args) {
Twitter twitter = TwitterFactory.getSingleton();
Query q =
new Query().query("twitter").count(100).resultType(Query.RECENT);
try {
while (q != null) {
QueryResult res = twitter.search(q);
System.out.printf("%d tweets.\n", res.getTweets().size());
q = res.nextQuery();
}
} catch (TwitterException e) {
e.printStackTrace();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment