Multiple queries in different methods Twitter4j Processing

qieuvxx

New Member
I am trying to execute separate queries in different methods, the code below is not my actual code but is just an example of the error, i have \[code\]Twitter twitter = new TwitterFactory(cb.build()).getInstance();\[/code\]called in both methods, however i get the error \[quote\] IllegalStateException: Cannot use this builder any longer, build() has already been called\[/quote\]if i make it global then i get the same error, this will probably be just me being stupid but i cant work it out, iv been staring at it for too long now.here is my code:\[code\]ConfigurationBuilder cb = new ConfigurationBuilder(); double lat = 51.5171; double lon = 0.1062; double res = 37; String resUnit = "mi";public void setup(){cb.setOAuthConsumerKey("XXXXXXXXXXXXXXXXXXXXXx");cb.setOAuthConsumerSecret("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");cb.setOAuthAccessToken("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");cb.setOAuthAccessTokenSecret("XXXXXXXXXXXXXXXXXXXXXXXXXXXX"); queryLon(); queryBir();}void queryLon(){try {Twitter twitter = new TwitterFactory(cb.build()).getInstance(); for (int j = 0; j < 5; j++) { Query query = new Query(); query.setRpp(100); QueryResult result = twitter.search(new Query().geoCode(new GeoLocation(lat,lon), res, resUnit)); ArrayList tweets = (ArrayList) result.getTweets(); for (int i = 0; i < tweets.size(); i++) { Tweet t = (Tweet) tweets.get(i);//User u= twitter.showUser("twitter");String location = t.getLocation();println("Location: " + location); }}}catch (TwitterException te) {println("Couldn't connect: " + te);};}void queryBir(){try {Twitter twitter = new TwitterFactory(cb.build()).getInstance(); for (int j = 0; j < 5; j++) { Query query = new Query(); query.setRpp(100); QueryResult result = twitter.search(new Query().geoCode(new GeoLocation(lat,lon), res, resUnit)); ArrayList tweets = (ArrayList) result.getTweets(); for (int i = 0; i < tweets.size(); i++) { Tweet t = (Tweet) tweets.get(i);String location = t.getLocation();println("Location: " + location); }}}catch (TwitterException te) {println("Couldn't connect: " + te);};}\[/code\]any help would be appreciated, cheers.forgot to mention im using Twitter4j and Processing
 
Top