I'm new to Processing, and programming in general. My goal is to leverage Twitter4j + Processing in order to retrieve large amounts of tweets that contain GeoLocation data. Currently, I am only able to parse through 100 results (presumably the limit per page) and retrieve those few tweets (1-5 on average) that actually contain geo data. I cannot figure out for the life of me how to parse through multiple pages of results from the Twitter API. Any suggestions would be greatly appreciated! Thanks in advance to everyone! I apologize if my inquiry is redundant -- but I have searched this forum to no avail re: this specific issue.
- void setup() {
- ConfigurationBuilder cb = new ConfigurationBuilder();
- cb.setOAuthConsumerKey("xxxx");
- cb.setOAuthConsumerSecret("xxxx");
- cb.setOAuthAccessToken("xxxx");
- cb.setOAuthAccessTokenSecret("xxxx");
- Twitter twitter = new TwitterFactory(cb.build()).getInstance();
- Query query = new Query("#peace");
- query.setCount(100);
- try {
- QueryResult result = twitter.search(query);
- ArrayList tweets = (ArrayList) result.getTweets();
- for (int i = 0; i < tweets.size(); i++) {
- Status t = (Status) tweets.get(i);
- GeoLocation loc = t.getGeoLocation();
- if (loc!=null) {
- tweets.get(i++);
- String user = t.getUser().getScreenName();
- String msg = t.getText();
- Double lat = t.getGeoLocation().getLatitude();
- Double lon = t.getGeoLocation().getLongitude();
- println("USER: " + user + " wrote: " + msg + " located at " + lat + ", " + lon);
- }
- }
- }
- catch (TwitterException te) {
- println("Couldn't connect: " + te);
- };
- }
- void draw() {
- }
1