List of usage examples for twitter4j TwitterException getMessage
@Override
public String getMessage()
From source file:twitter4j.examples.account.UpdateProfile.java
License:Apache License
/** * Usage: java twitter4j.examples.account.UpdateProfile [name] [url] [location] [description] * * @param args message//from ww w.j a va2 s . c o m */ public static void main(String[] args) { if (args.length < 4) { System.out.println( "Usage: java twitter4j.examples.account.UpdateProfile [name] [url] [location] [description]"); System.exit(-1); } try { Twitter twitter = new TwitterFactory().getInstance(); twitter.updateProfile(args[0], args[1], args[2], args[3]); System.out.println("Successfully updated profile."); System.exit(0); } catch (TwitterException te) { te.printStackTrace(); System.out.println("Failed to update profile: " + te.getMessage()); System.exit(-1); } }
From source file:twitter4j.examples.account.UpdateProfileImage.java
License:Apache License
/** * Usage: java twitter4j.examples.account.UpdateProfileImage [image file path] * * @param args message//from www . ja v a 2s.com */ public static void main(String[] args) { if (args.length < 1) { System.out.println("Usage: java twitter4j.examples.account.UpdateProfileImage [image file path]"); System.exit(-1); } try { Twitter twitter = new TwitterFactory().getInstance(); twitter.updateProfileImage(new File(args[0])); System.out.println("Successfully updated profile image."); System.exit(0); } catch (TwitterException te) { te.printStackTrace(); System.out.println("Failed to update profile image: " + te.getMessage()); System.exit(-1); } }
From source file:twitter4j.examples.account.VerifyCredentials.java
License:Apache License
/** * Usage: java twitter4j.examples.account.VerifyCredentials * * @param args message//w w w. ja v a2 s .c o m */ public static void main(String[] args) { try { Twitter twitter = new TwitterFactory().getInstance(); User user = twitter.verifyCredentials(); System.out.println("Successfully verified credentials of " + user.getScreenName()); System.exit(0); } catch (TwitterException te) { te.printStackTrace(); System.out.println("Failed to verify credentials: " + te.getMessage()); System.exit(-1); } }
From source file:twitter4j.examples.block.CreateBlock.java
License:Apache License
/** * Usage: java twitter4j.examples.block.CreateBlock [screen name] * * @param args message/*from ww w .ja v a 2s . c om*/ */ public static void main(String[] args) { if (args.length < 1) { System.out.println("Usage: java twitter4j.examples.block.CreateBlock [screen name]"); System.exit(-1); } try { Twitter twitter = new TwitterFactory().getInstance(); twitter.createBlock(args[0]); System.out.println("Successfully blocked user [" + args[0] + "]."); System.exit(0); } catch (TwitterException te) { te.printStackTrace(); System.out.println("Failed to block user: " + te.getMessage()); System.exit(-1); } }
From source file:twitter4j.examples.block.DestroyBlock.java
License:Apache License
/** * Usage: java twitter4j.examples.block.DestroyBlock [screen name] * * @param args message/*from ww w. j a va 2 s .c o m*/ */ public static void main(String[] args) { if (args.length < 1) { System.out.println("Usage: java twitter4j.examples.block.DestroyBlock [screen name]"); System.exit(-1); } try { Twitter twitter = new TwitterFactory().getInstance(); twitter.destroyBlock(args[0]); System.out.println("Successfully unblocked user [" + args[0] + "]."); System.exit(0); } catch (TwitterException te) { te.printStackTrace(); System.out.println("Failed to unblock user: " + te.getMessage()); System.exit(-1); } }
From source file:twitter4j.examples.block.GetBlockingUsers.java
License:Apache License
/** * Usage: java twitter4j.examples.block.GetBlockingUsers * * @param args message/*from w ww.j av a2 s .co m*/ */ public static void main(String[] args) { try { Twitter twitter = new TwitterFactory().getInstance(); int page = 1; List<User> users; do { users = twitter.getBlocksList(page); for (User user : users) { System.out.println("@" + user.getScreenName()); } page++; // this code ends up in an infinite loop due to the issue 1988 // http://code.google.com/p/twitter-api/issues/detail?id=1988 } while (users.size() > 0 && page <= 10); System.out.println("done."); System.exit(0); } catch (TwitterException te) { te.printStackTrace(); System.out.println("Failed to get blocking users: " + te.getMessage()); System.exit(-1); } }
From source file:twitter4j.examples.block.GetBlockingUsersIDs.java
License:Apache License
/** * Usage: java twitter4j.examples.block.GetBlockingUsersIDs * * @param args message//from w w w . java 2 s .c om */ public static void main(String[] args) { try { Twitter twitter = new TwitterFactory().getInstance(); IDs ids = twitter.getBlocksIDs(); 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 blocking user ids: " + te.getMessage()); System.exit(-1); } }
From source file:twitter4j.examples.directmessage.GetDirectMessages.java
License:Apache License
/** * Usage: java twitter4j.examples.directmessage.GetDirectMessages * * @param args String[]// w w w . j a v a2s . co m */ public static void main(String[] args) { Twitter twitter = new TwitterFactory().getInstance(); try { String cursor = null; int count = 20; DirectMessageList messages; do { System.out.println("* cursor:" + cursor); messages = cursor == null ? twitter.getDirectMessages(count) : twitter.getDirectMessages(count, cursor); for (DirectMessage message : messages) { System.out.println("From: " + message.getSenderId() + " id:" + message.getId() + " [" + message.getCreatedAt() + "]" + " - " + message.getText()); System.out.println("raw[" + message + "]"); } cursor = messages.getNextCursor(); } while (messages.size() > 0 && cursor != null); System.out.println("done."); System.exit(0); } catch (TwitterException te) { te.printStackTrace(); System.out.println("Failed to get messages: " + te.getMessage()); System.exit(-1); } }
From source file:twitter4j.examples.directmessage.SendDirectMessage.java
License:Apache License
/** * Usage: java twitter4j.examples.directMessage.DirectMessage [recipient screen name] [message] * * @param args String[]// www. j av a2 s . c o m */ public static void main(String[] args) { if (args.length < 2) { System.out.println( "Usage: java twitter4j.examples.directmessage.SendDirectMessage [recipient id] [message]"); System.exit(-1); } Twitter twitter = new TwitterFactory().getInstance(); try { DirectMessage message = twitter.sendDirectMessage(Long.parseLong(args[0]), args[1]); System.out.println("Direct message successfully sent to " + message.getId()); System.out.println(" details:" + message.toString()); System.exit(0); } catch (TwitterException te) { te.printStackTrace(); System.out.println("Failed to send a direct message: " + te.getMessage()); System.exit(-1); } }
From source file:twitter4j.examples.directmessage.ShowDirectMessage.java
License:Apache License
/** * Usage: java twitter4j.examples.directmessage.ShowDirectMessage [message id] * * @param args String[]/*from w w w. j a v a 2s .c o m*/ */ public static void main(String[] args) { if (args.length < 1) { System.out.println("Usage: java twitter4j.examples.directmessage.ShowDirectMessage [message id]"); System.exit(-1); } Twitter twitter = new TwitterFactory().getInstance(); try { DirectMessage message = twitter.showDirectMessage(Long.parseLong(args[0])); System.out.println("From: id:" + message.getId() + " - " + message.getText()); System.exit(0); } catch (TwitterException te) { te.printStackTrace(); System.out.println("Failed to get message: " + te.getMessage()); System.exit(-1); } }