List of usage examples for twitter4j TwitterException getMessage
@Override
public String getMessage()
From source file:twitter4j.examples.list.ShowUserListSubscription.java
License:Apache License
/** * Usage: java twitter4j.examples.list.ShowUserListSubscription [list id] [user id] * * @param args message//from w w w .j a v a 2 s . co m */ public static void main(String[] args) { if (args.length < 2) { System.out.println("Usage: java twitter4j.examples.list.ShowUserListSubscription [list id] [user id]"); System.exit(-1); } try { Twitter twitter = new TwitterFactory().getInstance(); long listId = Long.parseLong(args[0]); UserList list = twitter.showUserList(listId); long userId = Integer.parseInt(args[1]); User user = twitter.showUser(userId); try { twitter.showUserListSubscription(listId, userId); System.out.println("@" + user.getScreenName() + " is subscribing the list:" + list.getName()); } catch (TwitterException te) { if (te.getStatusCode() == 404) { System.out.println( "@" + user.getScreenName() + " is not subscribing the list:" + list.getName()); } } System.exit(0); } catch (TwitterException te) { te.printStackTrace(); System.out.println("Failed to check user subscription: " + te.getMessage()); System.exit(-1); } }
From source file:twitter4j.examples.list.UpdateUserList.java
License:Apache License
/** * Usage: java twitter4j.examples.list.UpdateUserList [list id] [new list name] [new description] * * @param args message/*from w w w .j a va2s .c om*/ */ public static void main(String[] args) { if (args.length < 3) { System.out.println( "Usage: java twitter4j.examples.list.UpdateUserList [list id] [new list name] [new description]"); System.exit(-1); } try { Twitter twitter = new TwitterFactory().getInstance(); twitter.updateUserList(Integer.parseInt(args[0]), args[1], true, args[2]); System.out.println("Successfully updated list [" + args[0] + "]."); System.exit(0); } catch (TwitterException te) { te.printStackTrace(); System.out.println("Failed to update list: " + te.getMessage()); System.exit(-1); } }
From source file:twitter4j.examples.mute.GetMutingUsersIDs.java
License:Apache License
/** * Usage: java twitter4j.examples.mute.GetMutingUsersIDs */* w w w . j av a2 s. c om*/ * @param args message */ public static void main(String[] args) { try { Twitter twitter = new TwitterFactory().getInstance(); IDs ids = twitter.getMutesIDs(-1L); for (long id : ids.getIDs()) { System.out.println(id); } System.out.println("done."); System.exit(0); } catch (TwitterException te) { te.printStackTrace(); System.out.println("Failed to get muting user ids: " + te.getMessage()); System.exit(-1); } }
From source file:twitter4j.examples.savedsearches.CreateSavedSearch.java
License:Apache License
/** * Usage: java twitter4j.examples.savedsearches.CreateSavedSearch [query] * * @param args message/*w w w. j av a2 s . com*/ */ public static void main(String[] args) { if (args.length < 1) { System.out.println("Usage: java twitter4j.examples.savedsearches.CreateSavedSearch [query]"); System.exit(-1); } try { Twitter twitter = new TwitterFactory().getInstance(); SavedSearch savedSearch = twitter.createSavedSearch(args[0]); System.out.println("Successfully created saved search [name:" + savedSearch.getName() + " query:" + savedSearch.getQuery() + " id:" + savedSearch.getId() + "]"); System.exit(0); } catch (TwitterException te) { te.printStackTrace(); System.out.println("Failed to create a saved search: " + te.getMessage()); System.exit(-1); } }
From source file:twitter4j.examples.savedsearches.DestroySavedSearch.java
License:Apache License
/** * Usage: java twitter4j.examples.savedsearches.DestroySavedSearch [saved search id] * * @param args message//from w w w. j av a 2s . co m */ public static void main(String[] args) { if (args.length < 1) { System.out.println("Usage: java twitter4j.examples.savedsearches.DestroySavedSearch [saved search id]"); System.exit(-1); } try { Twitter twitter = new TwitterFactory().getInstance(); SavedSearch savedSearch = twitter.destroySavedSearch(Integer.parseInt(args[0])); System.out.println("Successfully deleted saved search [name:" + savedSearch.getName() + " query:" + savedSearch.getQuery() + " id:" + savedSearch.getId() + "]"); System.exit(0); } catch (TwitterException te) { te.printStackTrace(); System.out.println("Failed to delete the saved search: " + te.getMessage()); System.exit(-1); } }
From source file:twitter4j.examples.savedsearches.GetSavedSearches.java
License:Apache License
/** * Usage: java twitter4j.examples.savedsearches.GetSavedSearches * * @param args message/* w w w . ja v a 2s .c om*/ */ public static void main(String[] args) { try { Twitter twitter = new TwitterFactory().getInstance(); List<SavedSearch> savedSearches = twitter.getSavedSearches(); for (SavedSearch savedSearch : savedSearches) { System.out.println("[name:" + savedSearch.getName() + " query:" + savedSearch.getQuery() + " id:" + savedSearch.getId() + "]"); } System.exit(0); } catch (TwitterException te) { te.printStackTrace(); System.out.println("Failed to retrieve saved searches: " + te.getMessage()); System.exit(-1); } }
From source file:twitter4j.examples.savedsearches.ShowSavedSearch.java
License:Apache License
/** * Usage: java twitter4j.examples.savedsearches.ShowSavedSearch [saved search id] * * @param args message//from www .j a v a 2 s . c om */ public static void main(String[] args) { if (args.length < 1) { System.out.println("Usage: java twitter4j.examples.savedsearches.ShowSavedSearch [saved search id]"); System.exit(-1); } try { Twitter twitter = new TwitterFactory().getInstance(); SavedSearch savedSearch = twitter.showSavedSearch(Integer.parseInt(args[0])); System.out.println("[name:" + savedSearch.getName() + " query:" + savedSearch.getQuery() + " id:" + savedSearch.getId() + "]"); System.exit(0); } catch (TwitterException te) { te.printStackTrace(); System.out.println("Failed to get the saved search: " + te.getMessage()); System.exit(-1); } }
From source file:twitter4j.examples.spamreporting.ReportSpam.java
License:Apache License
/** * Usage: java twitter4j.examples.spamreporting.ReportSpam [screen name] * * @param args String[]//w ww .j ava2 s. c o m */ public static void main(String[] args) { if (args.length < 1) { System.out.println("java twitter4j.examples.spamreporting.ReportSpam [screen name]"); System.exit(-1); } try { Twitter twitter = new TwitterFactory().getInstance(); System.out.println( "Successfully reported @" + twitter.reportSpam(args[0]).getScreenName() + " as a spammer."); } catch (TwitterException te) { te.printStackTrace(); System.out.println("Failed to report spam: " + te.getMessage()); System.exit(-1); } }
From source file:twitter4j.examples.suggestedusers.GetMemberSuggestions.java
License:Apache License
/** * Usage: java twitter4j.examples.suggestedusers.GetMemberSuggestions [slug] * * @param args message// w w w . j a va2 s . c o m */ public static void main(String[] args) { if (args.length < 1) { System.out.println("Usage: java twitter4j.examples.suggestedusers.GetMemberSuggestions [slug]"); System.exit(-1); } System.out.println("Showing suggested users in " + args[0] + " category."); try { Twitter twitter = new TwitterFactory().getInstance(); ResponseList<User> users = twitter.getMemberSuggestions(args[0]); for (User user : users) { if (user.getStatus() != null) { System.out.println("@" + user.getScreenName() + " - " + user.getStatus().getText()); } else { // the user is protected System.out.println("@" + user.getScreenName()); } } System.out.println("done."); System.exit(0); } catch (TwitterException te) { te.printStackTrace(); System.out.println("Failed to get suggested users: " + te.getMessage()); System.exit(-1); } }
From source file:twitter4j.examples.suggestedusers.GetSuggestedUserCategories.java
License:Apache License
/** * Usage: java twitter4j.examples.suggestedusers.GetSuggestedUserCategories * * @param args message/*from ww w. j a v a 2s . c o m*/ */ public static void main(String[] args) { try { Twitter twitter = new TwitterFactory().getInstance(); System.out.println("Showing suggested user categories."); ResponseList<Category> categories = twitter.getSuggestedUserCategories(); for (Category category : categories) { System.out.println(category.getName() + ":" + category.getSlug()); } System.out.println("done."); System.exit(0); } catch (TwitterException te) { te.printStackTrace(); System.out.println("Failed to get suggested categories: " + te.getMessage()); System.exit(-1); } }