I'm trying to make a sketch that gets the last 100 tweets from a specific user's twitter timeline. I'm using Twitter4j and the sketch works fine but I've learned that Twitter4J by default limits the timeline results to 20.
I've seen this page to learn about getting more than 100 when using Queries, but it seems to be working differently when trying to get a specific user's timeline. How to retrieve more than 100 results using Twitter4j
Thanks for looking!
Here is my sketch:
import twitter4j.conf.*;
import twitter4j.internal.async.*;
import twitter4j.internal.org.json.*;
import twitter4j.internal.logging.*;
import twitter4j.json.*;
import twitter4j.internal.util.*;
import twitter4j.management.*;
import twitter4j.auth.*;
import twitter4j.api.*;
import twitter4j.util.*;
import twitter4j.internal.http.*;
import twitter4j.*;
import twitter4j.internal.json.*;
ConfigurationBuilder cb = new ConfigurationBuilder();
cb.setOAuthConsumerKey("XXXXXX");
cb.setOAuthConsumerSecret("XXXXXX");
cb.setOAuthAccessToken("XXXXXX");
cb.setOAuthAccessTokenSecret("XXXXXX");
java.util.List statuses = null;
Twitter twitter = new TwitterFactory(cb.build()).getInstance();
String userName ="XXXXXX";
int numTweets = 100;
String[] twArray = new String[numTweets];
try {
statuses = twitter.getUserTimeline(userName);
}
catch(TwitterException e) {
}
for (int i=0; i<statuses.size(); i++) {
Status status = (Status)statuses.get(i);
//println(status.getUser().getName() + ": " + status.getText());
twArray[i] = status.getUser().getName() + ": " + status.getText();
}
println(twArray);