Load tweet search in the back.
in
Contributed Library Questions
•
2 years ago
Hi,
I'm trying to show the live stream of twitter. I found out how to get the data from twitter and this works nicely. But know I want to update this info so that new tweets are loaded when they are posted. I can put my "get tweets" lines in the draw() but this offcourse cause the framerate to go down very quickly. Is there a way to do this and not let the framerate go down??
Something like loading the data in the back so it is not messing up my animations...
Thanks,
Joost
Here's my code:
String msg = "Automatically posted from Processing";
//copy and paste these from your application in dev.twitter.com
String consumerKey = "***";
String consumerSecret = "***";
String accessToken = "***";
String accessSecret = "***";
AccessToken token;
Twitter myTwitter;
void setup(){
myTwitter = new TwitterFactory().getInstance();
myTwitter.setOAuthConsumer(consumerKey, consumerSecret);
token = new AccessToken(accessToken, accessSecret);
myTwitter.setOAuthAccessToken(token);
//
frameRate(30);
}
void draw(){
try{
//hashtag
Query queryHash = new Query("#durftevragen");
queryHash.setRpp(1);
QueryResult resultHash = myTwitter.search(queryHash);
ArrayList tweetHash = (ArrayList) resultHash.getTweets();
//get latest post
Tweet tHash = (Tweet) tweetHash.get(0);
String msgHash = tHash.getText();
println(msgHash);
println(frameRate); //println(tweets.size());
//}
}
catch(TwitterException te){
println("couldn't connect: " +te);
}
}
I'm trying to show the live stream of twitter. I found out how to get the data from twitter and this works nicely. But know I want to update this info so that new tweets are loaded when they are posted. I can put my "get tweets" lines in the draw() but this offcourse cause the framerate to go down very quickly. Is there a way to do this and not let the framerate go down??
Something like loading the data in the back so it is not messing up my animations...
Thanks,
Joost
Here's my code:
String msg = "Automatically posted from Processing";
//copy and paste these from your application in dev.twitter.com
String consumerKey = "***";
String consumerSecret = "***";
String accessToken = "***";
String accessSecret = "***";
AccessToken token;
Twitter myTwitter;
void setup(){
myTwitter = new TwitterFactory().getInstance();
myTwitter.setOAuthConsumer(consumerKey, consumerSecret);
token = new AccessToken(accessToken, accessSecret);
myTwitter.setOAuthAccessToken(token);
//
frameRate(30);
}
void draw(){
try{
//hashtag
Query queryHash = new Query("#durftevragen");
queryHash.setRpp(1);
QueryResult resultHash = myTwitter.search(queryHash);
ArrayList tweetHash = (ArrayList) resultHash.getTweets();
//get latest post
Tweet tHash = (Tweet) tweetHash.get(0);
String msgHash = tHash.getText();
println(msgHash);
println(frameRate); //println(tweets.size());
//}
}
catch(TwitterException te){
println("couldn't connect: " +te);
}
}
1