For my Uni project a have to get some Twitter Statuses.
When i try to pull out twitter status using Twitter4j, i always get only 20 results.
What i do...
Twitter twitter = tf.getInstance();
User user = twitter.verifyCredentials();
// Paging paging = new Paging(200); / i try with paging more than 20 but then result is 0;
statuses = twitter.getHomeTimeline();
is it some problem with lib and can you advice me which lib to use ?
By using the constructor with an int
you are actually setting the page
value and not adjusting the number of results to be returned. Instead you should do the following:
Paging paging = new Paging();
paging.setCount(200);
statuses = twitter.getHomeTimeline(paging);
Refer to the documentation on Paging
and Twitter's documentation for the API endpoint for more information.
By the way it's useful to know that not all API endpoints support all of the parameters that Paging
offers. For example 'get home timeline' doesn't support the page
parameter! Twitter4J has a guide on what parameters can be used with each API call here.