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 cu
This code works! (without exceeding rate limits). Referred twitter4j documentation and other answers on StackOverflow.
try {
// get friends
long cursor = -1;
PagableResponseList pagableFollowings;
do {
pagableFollowings = twitter.getFriendsList(twitter.getId(), cursor);
for (User user : pagableFollowings) {
listFriends.add(user); // ArrayList
}
} while ((cursor = pagableFollowings.getNextCursor()) != 0);
// get followers
cursor = -1;
PagableResponseList pagableFollowers;
do {
pagableFollowers = twitter.getFollowersList(twitter.getId(), cursor);
for (User user : pagableFollowers) {
listFollowers.add(user); // ArrayList
}
} while ((cursor = pagableFollowers.getNextCursor()) != 0);
} catch (TwitterException e) {
printError(e);
}