I'm using Twitter4j lib and made the code without setup() and draw()

The piece of code is used to print my first tweet from a selection of first eight tweets from my time line. I'm using Twitter4j lib and made the code without setup() and draw(). But now when I'm trying to put it in setup and draw(so that I can do something useful with that data), at one line(statuses..........something), it shows an error. I'm not able to put it in proper structure. Can any body help me here to put it in setup(), draw() etc. properly?

Thanks in advance

here's the code

import twitter4j.conf.*;
import twitter4j.internal.async.*;
import twitter4j.internal.org.json.*;
import twitter4j.internal.logging.*;
import twitter4j.json.*;
import twitter4j.internal.util.*;
import twitter4j.management.*;
import twitter4j.auth.*;
import twitter4j.api.*;
import twitter4j.util.*;
import twitter4j.internal.http.*;
import twitter4j.*;
import twitter4j.internal.json.*;


ConfigurationBuilder cb = new ConfigurationBuilder();

cb.setOAuthConsumerKey("2RFAFT5byUm484CR0zGZBA");
cb.setOAuthConsumerSecret("nGP2407kktbbGUMCmbyYNzJkL7oa2U6rUMFcamy9FE");
cb.setOAuthAccessToken("2324026551-iLLFWRbe2HP0TM6q3i4FIXqjZ6MSXutZYGnzwed");
cb.setOAuthAccessTokenSecret("f4v3aAucDqK5ASmMOpPu0LUUd3B8RhiO9SFF2MUwgK5pR");

java.util.List statuses = null;

Twitter twitter = new TwitterFactory(cb.build()).getInstance();

String userName ="dattasaurabh82";
int numTweets = 100;
String[] twArray = new String[numTweets];


try {

  Paging page = new Paging (1, 8);//page number, number per page
  statuses = twitter.getUserTimeline(userName, page);

 // statuses = twitter.getUserTimeline(userName);
}
catch(TwitterException e) {
}

for (int i=0; i<statuses.size(); i++) {
  Status status = (Status)statuses.get(i);

  //println(status.getUser().getName() + ": " + status.getText());
  twArray[i] = status.getUser().getName() + ": " + status.getText();
}


//println(twArray[2]);
String latestUpdate = twArray[0];
println(latestUpdate);
Tagged:

Answers

Sign In or Register to comment.