Java examples for Social Media:Twitter
Use twitter ConfigurationBuilder
import twitter4j.Twitter; import twitter4j.TwitterException; import twitter4j.TwitterFactory; import twitter4j.conf.ConfigurationBuilder; public class Test2 { private static String user = "Mr_Faton"; private static String consumerKey = "key"; private static String consumerSecret = "key"; private static String accessToken = "token"; private static String accessTokenSecret = "token"; public static void main(String[] args) { ConfigurationBuilder configurationBuilder = new ConfigurationBuilder(); configurationBuilder.setOAuthConsumerKey(consumerKey); configurationBuilder.setOAuthConsumerSecret(consumerSecret); configurationBuilder.setOAuthAccessToken(accessToken); configurationBuilder.setOAuthAccessTokenSecret(accessTokenSecret); TwitterFactory twitterFactory = new TwitterFactory( configurationBuilder.build()); Twitter twitter = twitterFactory.getInstance(); try {//from w ww . ja v a 2 s . c o m System.out.println(twitter.getScreenName()); } catch (TwitterException e) { e.printStackTrace(); } } }