Java examples for Social Media:Twitter
Manage Saved Searches in twitter
import twitter4j.*; import twitter4j.auth.AccessToken; import java.util.List; public class ManageSavedSearches { public static void main(String[] args) { Twitter twitter = new TwitterFactory().getInstance(); String consumerKey = ""; String consumerSecret = ""; String accessToken = ""; String accessTokenSecret = ""; twitter.setOAuthConsumer(consumerKey, consumerSecret); twitter.setOAuthAccessToken(new AccessToken(accessToken, accessTokenSecret));// w w w. j a va 2 s .c om try { if (args.length == 2) { String command = args[0]; if ("create".equals(command)) { String query = args[1]; twitter.createSavedSearch(query); System.out.println(query); } else if ("delete".equals(command)) { int id = Integer.parseInt(args[1]); twitter.destroySavedSearch(id); } } System.out.println("@" + twitter.getScreenName()); List<SavedSearch> savedSearches = twitter.getSavedSearches(); for (SavedSearch savedSearch : savedSearches) { System.out.println(savedSearch.getQuery() + " (id:" + savedSearch.getId() + ")"); } } catch (TwitterException te) { System.out.println(te.getMessage()); } } }