Loading...
Processing Forum
Recent Topics
All Forums
Screen name:
moseso
moseso's Profile
1
Posts
0
Responses
0
Followers
Activity Trend
Last 30 days
Last 30 days
Date Interval
From Date :
To Date :
Go
Loading Chart...
Posts
Responses
PM
Show:
All
Discussions
Questions
Expanded view
List view
Private Message
Processing and twitter
[1 Reply]
20-Feb-2013 02:11 PM
Forum:
Contributed Library Questions
Hi guys,
im stuck with this code. I want the words put in to the message ArrayList to show up on the GUI when I run the program but they will not. can any body help. the code is below any help will be greatly appreciated:
import java.util.Date;
//
ConfigurationBuilder cb;
//New Twitter
Twitter twitter;
//New query
Query query;
//User
User u;
//text font
PFont twext;
//user
String user;
//message
String msg;
//msg ArrayList
ArrayList <String> message = new ArrayList();
void setup(){
size(550,550);
background(0);
smooth();
cb = new ConfigurationBuilder();
cb.setOAuthConsumerKey("Obv5PpGl0IHKgubEy3IOow");
cb.setOAuthConsumerSecret("4DQi7umt82XoxgasVzL8F3vqnKGvE9GuycnUpa76M");
cb.setOAuthAccessToken("1188433046-4B3LDBloK1hWmDFtjHUaJSBvWRcDxuT4ce6zZTf");
cb.setOAuthAccessTokenSecret("e7lIbNSGNaK8k7luha1FxyYSHwPPFV8SzC8X9bYEQz4");
twitter = new TwitterFactory(cb.build()).getInstance();
query = new Query("hope");
query.count(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);
User u=(User) t.getUser();
String user= u.getName();
String msg = t.getText();
// text(user + ": " + msg, 10, 30);
println(user + ": " + msg);
//fill(0,102,153,204);
//Tweets split into words - bad and good
String[] input = msg.split(" ");
for(int j = 0; j< input.length; j++){
if((input[j] == "bad") || (input[j] == "good")){
message.add(input[j]);
};
};
};
}
catch (TwitterException te) {
println("Couldn't connect: " + te);
};
};
void draw() {
//Draw a faint black rectangle over what is currently on the stage so it fades over time.
fill(0,1);
rect(0,0,width,height);
//Draw a word from the list of words that we've built
// int i = (frameCount % message.size());
// String word = message.get(i);
//Put it somewhere random on the stage, with a random size and colour
for(int x = 0; x< message.size();x++){
fill(255,random(50,150));
textSize(random(10,30));
text(message.get(x), random(width), random(height));
};
}
«Prev
Next »
Moderate user : moseso
Forum