import java.util.List;
import twitter4j.TwitterException;
import twitter4j.TwitterFactory;
import twitter4j.conf.ConfigurationBuilder;
import twitter4j.*;
public class Twitter_app {
public static void main(String[] args) throws TwitterException {
// TODO Auto-generated method stub
try
{
ConfigurationBuilder cb= new ConfigurationBuilder();
cb.setDebugEnabled(true)
.setOAuthConsumerKey("XXX")
.setOAuthConsumerSecret("XXXX")
.setOAuth2AccessToken("XXXXX")
.setOAuthAccessTokenSecret("XXXXXX")
;
TwitterFactory tf= new TwitterFactory(cb.build()); //configurations
Twitter twitter= tf.getInstance();
List<Status> statuses = twitter.getHomeTimeline(); //get timeline
System.out.println("Showing @" + twitter.getScreenName() + "'s home timeline."); //getting user's screen name
for(Status status : statuses)
{
System.out.println("@" + status.getUser().getScreenName() + " - " + status.getText());
}
}
catch(TwitterException te) {
te.printStackTrace();
System.out.println("Failed to get timeline: " + te.getMessage());
System.exit(-1);
}
}
}
But i get this the kwown error message "Authentication credentials are missing. See http://twitter4j.org/en/configuration.html for the detail." I am not able to find the error. Any help?
You used setOAuth2AccessToken, the html page only has setOAuthAccessToken. Maybe you want to remove the '2' and try again.