Example usage for twitter4j Twitter lookupFriendships

List of usage examples for twitter4j Twitter lookupFriendships

Introduction

In this page you can find the example usage for twitter4j Twitter lookupFriendships.

Prototype

ResponseList<Friendship> lookupFriendships(long... ids) throws TwitterException;

Source Link

Document

Returns the relationship of the authenticating user to the specified users.

Usage

From source file:com.SocialAccess.TwitterSearch.java

public static void ShowFriendsListNames() {
    List<String[]> data = CSVutil.readCSV(Constants.CSV_FILE_NAME);
    String[] people = data.get(0);
    try {/*w w  w.ja  va2 s.  co  m*/
        Twitter twitter = new TwitterFactory().getInstance();
        ResponseList<Friendship> friendships = twitter.lookupFriendships(people);
        for (Friendship friendship : friendships) {
            System.out.println("@" + friendship.getScreenName() + " following: " + friendship.isFollowing()
                    + " followed_by: " + friendship.isFollowedBy());
        }
        System.out.println("Successfully looked up friendships [" + people[0] + "].");
        System.exit(0);
    } catch (TwitterException te) {
        te.printStackTrace();
        System.out.println("Failed to lookup 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  ww w .  ja  v a 2s  .c o  m*/
 */
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);
    }
}