Java examples for Social Media:Twitter
Search Twitter user screen name and user name
import twitter4j.*; import twitter4j.auth.AccessToken; public class SearchUsers { public static void main(String[] args) { if (args.length < 1) { System.exit(-1);/*from www. ja va2 s . c o m*/ } Twitter twitter = new TwitterFactory().getInstance(); String consumerKey = ""; String consumerSecret = ""; String accessToken = ""; String accessTokenSecret = ""; twitter.setOAuthConsumer(consumerKey, consumerSecret); twitter.setOAuthAccessToken(new AccessToken(accessToken, accessTokenSecret)); try { ResponseList<User> users = twitter.searchUsers(args[0], 1); for (User user : users) { System.out.println("@" + user.getScreenName() + " - " + user.getName()); } System.exit(0); } catch (TwitterException te) { te.printStackTrace(); System.out.println(te.getMessage()); System.exit(-1); } } }