ONE_FE
ONE_FE

Reputation: 996

tw cannot be resolved in twitter4j

I'm using twitter4j to recognize a user. However, piece of code written to recognize the user throws an error.

twitterStream.addListener(listener);
    User user = tw.showUser("lalindasampath"); //tw is your Twitter variable from twitter4j.Twitter tw=tf.getInstance();
    long id = user.getId();
    twitterStream.addListener(listener);
    FilterQuery filtre = new FilterQuery();
    filtre.follow(id);
    twitterStream.filter(filtre);

My error is : tw cannot be resolved.

Does anyone know what should I import to fix this error?

Upvotes: 1

Views: 863

Answers (1)

FeanDoe
FeanDoe

Reputation: 1668

You have to create the Twitter tw variable as you did on your other question. Something like this:

    ConfigurationBuilder cb = new ConfigurationBuilder();
       cb.setDebugEnabled(true)
            .setOAuthConsumerKey("")
            .setOAuthConsumerSecret("")
            .setOAuthAccessToken("")
            .setOAuthAccessTokenSecret("");
 TwitterFactory tf=new TwitterFactory(cb.build());  
 twitter4j.Twitter tw=tf.getInstance();

Upvotes: 1

Related Questions