Search code examples
javafacebookrestfb

Unable to get the other details of the users in the friend's list of fb?


This is the code that i used.I am only able to get the name and ids of the friends and no other details

    FacebookClient fb=new DefaultFacebookClient(ACCESS_TOKEN);  

    Connection<User> myFriends = fb.fetchConnection("me/friends", User.class);

    List<User> users=myFriends.getData();

    for(Iterator iterator=users.iterator();iterator.hasNext();)

    {
        User user=(User)iterator.next();

        System.out.println(user.getRelationshipStatus());

    }

Solution

  • Getting only the name and id is the expected result.

    You can change it by specifying which fields you want to get back. In restfb it should be something like:

    Connection<User> myFriends = fb.fetchConnection("me/friends", User.class, 
        Parameter.with("fields", "id,first_name,last_name,name,gender"));
    

    Add anything else you need and have permission for.