List of usage examples for twitter4j TwitterException getMessage
@Override
public String getMessage()
From source file:twitter4j.examples.friendship.ShowFriendship.java
License:Apache License
/** * Usage: java twitter4j.examples.friendship.ShowFriendship [source screen name] [target screen name] * * @param args message/*from w ww . j a va 2 s. co m*/ */ public static void main(String[] args) { if (args.length < 2) { System.out.println( "Usage: java twitter4j.examples.friendship.ShowFriendship [source screen name] [target screen name]"); System.exit(-1); } try { Twitter twitter = new TwitterFactory().getInstance(); Relationship relationship = twitter.showFriendship(args[0], args[1]); System.out.println("isSourceBlockingTarget: " + relationship.isSourceBlockingTarget()); System.out.println("isSourceFollowedByTarget: " + relationship.isSourceFollowedByTarget()); System.out.println("isSourceFollowingByTarget: " + relationship.isSourceFollowingTarget()); System.out.println("isSourceNotificationsEnabled: " + relationship.isSourceNotificationsEnabled()); System.out.println("canSourceDm: " + relationship.canSourceDm()); System.exit(0); } catch (TwitterException te) { te.printStackTrace(); System.out.println("Failed to show friendship: " + te.getMessage()); System.exit(-1); } }
From source file:twitter4j.examples.friendship.UpdateFriendship.java
License:Apache License
/** * Usage: java twitter4j.examples.user.UpdateFriendship [screen name] [enable device notification(true|false)] [enable retweets(true|false)] * * @param args message/* w w w . j a v a 2s. c o m*/ */ public static void main(String[] args) { if (args.length < 3) { System.out.println( "Usage: java twitter4j.examples.user.UpdateFriendship [screen name] [enable device notification(true|false)] [enable retweets(true|false)]"); System.exit(-1); } try { Twitter twitter = new TwitterFactory().getInstance(); Relationship relationship = twitter.updateFriendship(args[0], Boolean.parseBoolean(args[1]), Boolean.parseBoolean(args[2])); System.out.println( "Successfully updated the friendship of [" + relationship.getTargetUserScreenName() + "]."); System.exit(0); } catch (TwitterException te) { te.printStackTrace(); System.out.println("Failed to update the friendship: " + te.getMessage()); System.exit(-1); } }
From source file:twitter4j.examples.geo.GetGeoDetails.java
License:Apache License
/** * Usage: java twitter4j.examples.geo.GetGeoDetails [place id] * * @param args message/*w ww .java 2 s .c o m*/ */ public static void main(String[] args) { if (args.length < 1) { System.out.println("Usage: java twitter4j.examples.geo.GetGeoDetails [place id]"); System.exit(-1); } try { Twitter twitter = new TwitterFactory().getInstance(); Place place = twitter.getGeoDetails(args[0]); System.out.println("name: " + place.getName()); System.out.println("country: " + place.getCountry()); System.out.println("country code: " + place.getCountryCode()); System.out.println("full name: " + place.getFullName()); System.out.println("id: " + place.getId()); System.out.println("place type: " + place.getPlaceType()); System.out.println("street address: " + place.getStreetAddress()); Place[] containedWithinArray = place.getContainedWithIn(); if (containedWithinArray != null && containedWithinArray.length != 0) { System.out.println(" contained within:"); for (Place containedWithinPlace : containedWithinArray) { System.out.println(" id: " + containedWithinPlace.getId() + " name: " + containedWithinPlace.getFullName()); } } System.exit(0); } catch (TwitterException te) { te.printStackTrace(); System.out.println("Failed to retrieve geo details: " + te.getMessage()); System.exit(-1); } }
From source file:twitter4j.examples.help.GetPrivacyPolicy.java
License:Apache License
/** * Usage: java twitter4j.examples.help.GetPrivacyPolicy * * @param args String[]/* w w w.j a v a 2s.co m*/ */ public static void main(String[] args) { try { Twitter twitter = new TwitterFactory().getInstance(); System.out.println(twitter.getPrivacyPolicy()); } catch (TwitterException te) { te.printStackTrace(); System.out.println("Failed to get privacy policy: " + te.getMessage()); System.exit(-1); } }
From source file:twitter4j.examples.help.GetTermsOfService.java
License:Apache License
/** * Usage: java twitter4j.examples.help.GetTermsOfService * * @param args String[]// w w w . j av a 2 s .co m */ public static void main(String[] args) { try { Twitter twitter = new TwitterFactory().getInstance(); System.out.println(twitter.getTermsOfService()); } catch (TwitterException te) { te.printStackTrace(); System.out.println("Failed to get tems of service: " + te.getMessage()); System.exit(-1); } }
From source file:twitter4j.examples.json.LoadRawJSON.java
License:Apache License
/** * Usage: java twitter4j.examples.json.LoadRawJSON * * @param args String[]// w w w . j av a 2 s.c o m */ public static void main(String[] args) { try { File[] files = new File("statuses").listFiles(new FilenameFilter() { @Override public boolean accept(File dir, String name) { return name.endsWith(".json"); } }); for (File file : files) { String rawJSON = readFirstLine(file); Status status = TwitterObjectFactory.createStatus(rawJSON); System.out.println("@" + status.getUser().getScreenName() + " - " + status.getText()); } System.exit(0); } catch (IOException ioe) { ioe.printStackTrace(); System.out.println("Failed to store tweets: " + ioe.getMessage()); } catch (TwitterException te) { te.printStackTrace(); System.out.println("Failed to get timeline: " + te.getMessage()); System.exit(-1); } }
From source file:twitter4j.examples.list.CreateUserList.java
License:Apache License
/** * Usage: java twitter4j.examples.list.CreateUserList [list name] [list description] * * @param args message/*from w w w .j a v a2 s. c om*/ */ public static void main(String[] args) { if (args.length < 1) { System.out.println("Usage: java twitter4j.examples.list.CreateUserList [list name] [list description]"); System.exit(-1); } try { Twitter twitter = new TwitterFactory().getInstance(); String description = null; if (args.length >= 2) { description = args[1]; } UserList list = twitter.createUserList(args[0], true, description); System.out .println("Successfully created a list (id:" + list.getId() + ", slug:" + list.getSlug() + ")."); System.exit(0); } catch (TwitterException te) { te.printStackTrace(); System.out.println("Failed to create a list: " + te.getMessage()); System.exit(-1); } }
From source file:twitter4j.examples.list.CreateUserListMember.java
License:Apache License
/** * Usage: java twitter4j.examples.list.CreateUserListMember [list id] [user id] * * @param args message//from w w w .ja va2 s .c om */ public static void main(String[] args) { if (args.length < 2) { System.out.println("Usage: java twitter4j.examples.list.CreateUserListMember [list id] [user id]"); System.exit(-1); } try { Twitter twitter = new TwitterFactory().getInstance(); twitter.createUserListMember(Integer.parseInt(args[0]), Integer.parseInt(args[1])); System.out.println("Successfully added the user to the specified list."); System.exit(0); } catch (TwitterException te) { te.printStackTrace(); System.out.println("Failed to add users: " + te.getMessage()); System.exit(-1); } }
From source file:twitter4j.examples.list.CreateUserListMembers.java
License:Apache License
/** * Usage: java twitter4j.examples.list.CreateUserListMembers [list id] [screen name[,screen name..]] * * @param args message// www . j av a 2 s . com */ public static void main(String[] args) { if (args.length < 2) { System.out.println( "Usage: java twitter4j.examples.list.CreateUserListMembers [list id] [screen name[,screen name..]]"); System.exit(-1); } try { Twitter twitter = new TwitterFactory().getInstance(); twitter.createUserListMembers(Integer.parseInt(args[0]), args[1].split(",")); System.out.println("Successfully added the user(s) to the specified list."); System.exit(0); } catch (TwitterException te) { te.printStackTrace(); System.out.println("Failed to add a user: " + te.getMessage()); System.exit(-1); } }
From source file:twitter4j.examples.list.CreateUserListSubscription.java
License:Apache License
/** * Usage: java twitter4j.examples.list.CreateUserListSubscription [list id] * * @param args message//from w w w . j a va 2 s . c om */ public static void main(String[] args) { if (args.length < 1) { System.out.println("Usage: java twitter4j.examples.list.CreateUserListSubscription [list id]"); System.exit(-1); } try { Twitter twitter = new TwitterFactory().getInstance(); twitter.createUserListSubscription(Integer.parseInt(args[0])); System.out.println("Successfully subscribed the list."); System.exit(0); } catch (TwitterException te) { te.printStackTrace(); System.out.println("Failed to subscribe the list: " + te.getMessage()); System.exit(-1); } }