Search code examples
javaeclipseapisizetwitter4j

Max 20 Friends Information on Twitter4J


Like you see in this code, I want to get all the information about friends in twitter, people I follow. But doing this :

PagableResponseList<User> users = twitter.getFriendsList(USER_ID, CURSOR);

... only gives me the first 20 recent friends... What can I do?

Complete code about it :

PagableResponseList<User> users = twitter.getFriendsList(USER_ID, CURSOR);
        User user = null;
        max = users.size();

        System.out.println("Following: "+max);
        for (int i = 0 ; i < users.size() ; i++){

            user = users.get(i);

            System.out.print("\nID: "+user.getId()+" / User: "+user.getName()+" /");
            System.out.print("\nFollowers: "+user.getFollowersCount()+"\n");

            tid.add(Long.parseLong(String.valueOf(user.getId())));
            tusername.add(user.getName());
            tfollowers.add(Long.parseLong(String.valueOf(user.getFollowersCount())));
            tname.add(user.getScreenName());

        }

Thanks..


Solution

  • I have the solution to my post... thanks to Sander, give me some ideas...

    The thing was change the for to while ((CURSOR = ids.getNextCursor()) != 0);.

    And... user = twitter.showUser(id);

    Playing with showUser makes it possible to get, with a slowly time, all the info about all my friends...

    That's all. Don't use user.get(i);