Example usage for twitter4j TwitterException getMessage

List of usage examples for twitter4j TwitterException getMessage

Introduction

In this page you can find the example usage for twitter4j TwitterException getMessage.

Prototype

@Override
    public String getMessage() 

Source Link

Usage

From source file:twitter4j.examples.favorite.CreateFavorite.java

License:Apache License

/**
 * Usage: java twitter4j.examples.favorite.CreateFavorite [status id]
 *
 * @param args message/*from  w  ww . j a v  a2 s .c  o  m*/
 */
public static void main(String[] args) {
    if (args.length < 1) {
        System.out.println("Usage: java twitter4j.examples.favorite.CreateFavorite [status id]");
        System.exit(-1);
    }
    try {
        Twitter twitter = new TwitterFactory().getInstance();
        twitter.createFavorite(Long.parseLong(args[0]));
        System.out.println("Successfully favorited status [" + args[0] + "].");
        System.exit(0);
    } catch (TwitterException te) {
        te.printStackTrace();
        System.out.println("Failed to favorite status: " + te.getMessage());
        System.exit(-1);
    }
}

From source file:twitter4j.examples.favorite.DestroyFavorite.java

License:Apache License

/**
 * Usage: java twitter4j.examples.favorite.DestroyFavorite [status id]
 *
 * @param args message//from w  ww  . j  ava 2s . com
 */
public static void main(String[] args) {
    if (args.length < 1) {
        System.out.println("Usage: java twitter4j.examples.favorite.DestroyFavorite [status id]");
        System.exit(-1);
    }
    try {
        Twitter twitter = new TwitterFactory().getInstance();
        twitter.destroyFavorite(Long.parseLong(args[0]));
        System.out.println("Successfully unfavorited status [" + args[0] + "].");
        System.exit(0);
    } catch (TwitterException te) {
        te.printStackTrace();
        System.out.println("Failed to unfavorite status: " + te.getMessage());
        System.exit(-1);
    }
}

From source file:twitter4j.examples.favorite.GetFavorites.java

License:Apache License

/**
 * Usage: java twitter4j.examples.favorite.GetFavorites
 *
 * @param args message/*w w  w . j  a va2 s .c om*/
 */
public static void main(String[] args) {
    try {
        Twitter twitter = new TwitterFactory().getInstance();
        List<Status> statuses = twitter.getFavorites();
        for (Status status : statuses) {
            System.out.println("@" + status.getUser().getScreenName() + " - " + status.getText());
        }
        System.out.println("done.");
        System.exit(0);
    } catch (TwitterException te) {
        te.printStackTrace();
        System.out.println("Failed to get favorites: " + te.getMessage());
        System.exit(-1);
    }
}

From source file:twitter4j.examples.friendsandfollowers.GetFollowersIDs.java

License:Apache License

/**
 * Usage: java twitter4j.examples.friendsandfollowers.GetFollowersIDs [screen name]
 *
 * @param args message//from   w w  w .  j a v  a 2 s .  c o  m
 */
public static void main(String[] args) {
    try {
        Twitter twitter = new TwitterFactory().getInstance();
        long cursor = -1;
        IDs ids;
        System.out.println("Listing followers's ids.");
        do {
            if (0 < args.length) {
                ids = twitter.getFollowersIDs(args[0], cursor);
            } else {
                ids = twitter.getFollowersIDs(cursor);
            }
            for (long id : ids.getIDs()) {
                System.out.println(id);
            }
        } while ((cursor = ids.getNextCursor()) != 0);
        System.exit(0);
    } catch (TwitterException te) {
        te.printStackTrace();
        System.out.println("Failed to get followers' ids: " + te.getMessage());
        System.exit(-1);
    }
}

From source file:twitter4j.examples.friendsandfollowers.GetFriendsIDs.java

License:Apache License

/**
 * Usage: java twitter4j.examples.friendsandfollowers.GetFriendsIDs [screen name]
 *
 * @param args message/*from w w w  .j a v a2 s .  c om*/
 */
public static void main(String[] args) {
    try {
        Twitter twitter = new TwitterFactory().getInstance();
        long cursor = -1;
        IDs ids;
        System.out.println("Listing following ids.");
        do {
            if (0 < args.length) {
                ids = twitter.getFriendsIDs(args[0], cursor);
            } else {
                ids = twitter.getFriendsIDs(cursor);
            }
            for (long id : ids.getIDs()) {
                System.out.println(id);
            }
        } while ((cursor = ids.getNextCursor()) != 0);
        System.exit(0);
    } catch (TwitterException te) {
        te.printStackTrace();
        System.out.println("Failed to get friends' ids: " + te.getMessage());
        System.exit(-1);
    }
}

From source file:twitter4j.examples.friendship.CreateFriendship.java

License:Apache License

/**
 * Usage: java twitter4j.examples.friendship.CreateFriendship [screen name]
 *
 * @param args message/*from ww  w  .j a v a2s  . c o  m*/
 */
public static void main(String[] args) {
    if (args.length < 1) {
        System.out.println("Usage: java twitter4j.examples.friendship.CreateFriendship [screen name]");
        System.exit(-1);
    }
    try {
        Twitter twitter = new TwitterFactory().getInstance();
        twitter.createFriendship(args[0]);
        System.out.println("Successfully followed [" + args[0] + "].");
        System.exit(0);
    } catch (TwitterException te) {
        te.printStackTrace();
        System.out.println("Failed to follow: " + te.getMessage());
        System.exit(-1);
    }
}

From source file:twitter4j.examples.friendship.DestroyFriendship.java

License:Apache License

/**
 * Usage: java twitter4j.examples.friendship.DestroyFriendship [screen name]
 *
 * @param args message//from   w  w  w.  j a v  a2 s .c  o m
 */
public static void main(String[] args) {
    if (args.length < 1) {
        System.out.println("Usage: java twitter4j.examples.friendship.DestroyFriendship [screen name]");
        System.exit(-1);
    }
    try {
        Twitter twitter = new TwitterFactory().getInstance();
        twitter.destroyFriendship(args[0]);
        System.out.println("Successfully unfollowed [" + args[0] + "].");
        System.exit(0);
    } catch (TwitterException te) {
        te.printStackTrace();
        System.out.println("Failed to unfollow: " + te.getMessage());
        System.exit(-1);
    }
}

From source file:twitter4j.examples.friendship.GetIncomingFriendships.java

License:Apache License

/**
 * Usage: java twitter4j.examples.friendship.GetIncomingFriendships
 *
 * @param args message/*from   w  ww. j a v  a 2  s  .  c o m*/
 */
public static void main(String[] args) {
    try {
        Twitter twitter = new TwitterFactory().getInstance();
        long cursor = -1;
        IDs ids;
        System.out.println("Showing incoming pending follow request(s).");
        do {
            ids = twitter.getIncomingFriendships(cursor);
            for (long id : ids.getIDs()) {
                System.out.println(id);
            }
        } while ((cursor = ids.getNextCursor()) != 0);
        System.exit(0);
    } catch (TwitterException te) {
        te.printStackTrace();
        System.out.println("Failed to get incoming friendships: " + te.getMessage());
        System.exit(-1);
    }
}

From source file:twitter4j.examples.friendship.GetOutgoingFriendships.java

License:Apache License

/**
 * Usage: java twitter4j.examples.friendship.GetOutgoingFriendships
 *
 * @param args message/*w ww  . j a va 2s .  c om*/
 */
public static void main(String[] args) {
    try {
        Twitter twitter = new TwitterFactory().getInstance();
        long cursor = -1;
        IDs ids;
        System.out.println("Showing outgoing pending follow request(s).");
        do {
            ids = twitter.getOutgoingFriendships(cursor);
            for (long id : ids.getIDs()) {
                System.out.println(id);
            }
        } while ((cursor = ids.getNextCursor()) != 0);
        System.exit(0);
    } catch (TwitterException te) {
        te.printStackTrace();
        System.out.println("Failed to get outgoing friendships: " + te.getMessage());
        System.exit(-1);
    }
}

From source file:twitter4j.examples.friendship.LookupFriendships.java

License:Apache License

/**
 * Usage: java twitter4j.examples.user.LookupFriendships [screen name[,screen name..]]
 *
 * @param args message/*from   w ww .  j av  a2s.  c om*/
 */
public static void main(String[] args) {
    if (args.length < 1) {
        System.out
                .println("Usage: java twitter4j.examples.user.LookupFriendships [screen name[,screen name..]]");
        System.exit(-1);
    }
    try {
        Twitter twitter = new TwitterFactory().getInstance();
        ResponseList<Friendship> friendships = twitter.lookupFriendships(args[0].split(","));
        for (Friendship friendship : friendships) {
            System.out.println("@" + friendship.getScreenName() + " following: " + friendship.isFollowing()
                    + " followed_by: " + friendship.isFollowedBy());
        }
        System.out.println("Successfully looked up friendships [" + args[0] + "].");
        System.exit(0);
    } catch (TwitterException te) {
        te.printStackTrace();
        System.out.println("Failed to lookup friendships: " + te.getMessage());
        System.exit(-1);
    }
}