0

I have processing 2.0 and twitter4j 3.0.3; when I try to run the program I get the error message "The function "getTweet() does not exist".

I have tried getStatuses instead to no avail, I get the same error message that the function does not exist.

Help?

ArrayList<String> words = new ArrayList();
TwitterFactory twitterFactory;
Twitter twitter;

void setup() {

  size(500, 500);
  background(0);
  smooth();
  connectTwitter();
}

 void draw() {
   //draw fade rectangle
   fill(0, 1);
   rect(0, 0, width, height);

   //draw arraylist words
   int i = (frameCount % words.size());
   String word = words.get(i);

   fill(255, random(50, 150));
   textSize(random(10, 30));
   text(word, random(width), random(height));
 }

// Initial connection
void connectTwitter() {

ConfigurationBuilder cb = new ConfigurationBuilder();
cb.setOAuthConsumerKey("FvnrJfRMsMUCEhL0xxPegQ");
cb.setOAuthConsumerSecret("ZSnKgo6EQmq9wVd5gCMbufcMP5ztFuQhVwKpJvDhAY");
cb.setOAuthAccessToken("274686457-ZiYxpWchtcwHod7UXPjLCj18djl9CyNrk1HMqtQx");
cb.setOAuthAccessTokenSecret("kafd2QHznAu4Mu0R9x5HNyeyA4J3UwCOpETQYeDU");

  twitterFactory = new TwitterFactory(cb.build());
  twitter = twitterFactory.getInstance();
  Query query = new Query("#BioshockInfinite");
  query.setCount(100);

  try {
    QueryResult result = twitter.search(query);
    ArrayList Status = (ArrayList) result.getTweet();

    for (int i = 0; i < tweet.size(); i++) {
      Status s = (Status) tweet.get(i);
      User user = s.getUser;
      String name = user.getName();
      String msg = s.getText();
      Date d = s.getCreatedAt();
      println("Tweet by" + user + "at" + d + ":" + msg);
     }  
  }
  catch (TwitterException te) {
    println("Couldn't connect:" + te);
  }
  }
Amber
  • 1

1 Answers1

0

I changed the line

ArrayList Status = (ArrayList) result.getTweet();

(which looks a bit odd anyway) to

List<Status> tweets = result.getTweets();

and I get Results now. Eclipse showed an error that getTweet() wants a List to store the Tweets.

Hyque
  • 718
  • 1
  • 6
  • 9