Collection of more than 100 tweets
in
Contributed Library Questions
•
2 years ago
Hello
With the help of processing forum I was able to refine my code for collecting tweets for a certain search word using Twitter 4j library. Here is the final script.... but I still have a limitation that this script only creates 100 latest tweets.
Can I increase the number to more than 100?
also Can I make the collection Time based....like for six hours or 24 hours? Kindly help me regarding this. The script is copied below.
Twitter myTwitter;
void setup() {
myTwitter = new Twitter("username", "password");
try {
Query query = new Query("music show, berlin");
query.setRpp(100);
QueryResult result = myTwitter.search(query);
ArrayList tweets = (ArrayList) result.getTweets();
for (int i = 0; i < tweets.size(); i++) {
Tweet t = (Tweet) tweets.get(i);
String user = t.getFromUser();
String msg = t.getText();
Date d = t.getCreatedAt();
GeoLocation geoloc = t.getGeoLocation();
try {
double lat = geoloc.getLatitude();
println("latitude: " + lat);
} catch (Exception e) {
println(e.getMessage());
println("no latitude");
}
try {
double lon = geoloc.getLongitude();
println("longitude: " + lon);
} catch (Exception e) {
println(e.getMessage());
println("no longitude");
}
println("Tweet by " + user + " at " + d + ": " + msg);
};
}
catch (TwitterException te) {
println("Couldn't connect: " + te);
};
};
void draw() {
};
1