Search code examples
javatwitter4j

Friends list of a friend using Twitter4J


How can I obtain the friends list of a friend or follower using Twitter4J?

Using getFriendsId(), I'm only able to retrieve the friend's/follower's list of that current user which is authenticated. What I want is to obtain the list of friends of a follower or friend of the authenticated user.


Solution

  • long lCursor = -1;
    IDs friendsIDs = twitter.getFriendsIDs(userID, lCursor);
    System.out.println(twitter.showUser(userID).getName());
    System.out.println("==========================");
    do
    {
      for (long i : friendsIDs.getIDs())
       {
           System.out.println("follower ID #" + i);
           System.out.println(twitter.showUser(i).getName());
       }
    }while(friendsIDs.hasNext());