Search code examples
iphoneiosobjective-cfb-graph

iOS : Getting FriendList along with respective name, id and picture using FBGraph API


You can get friendList along with respective name and id using FBGraph API like this:

  FbGraphResponse *fb_graph_response = [fbgraph doGraphGet:@"/me/friends" withGetVars:nil];

But how to get name, id and picture of all friends using FBGraph API?


Solution

  • You can get friendList along with respective name, id and picture using FBGraph API like this:

    NSDictionary *param=[NSDictionary dictionaryWithObjectsAndKeys:@"picture,name",@"fields", nil];
    
    FbGraphResponse *fb_graph_response = [fbgraph doGraphGet:@"/me/friends" withGetVars:param];
    

    Response will be

    data = {
       id = 100001625299089;
       name = "Name here";
       picture = {
                  data = {
                          s_silhouette" = 0;
                          url = "url here";
                          };
                  };
     },
        //all other friends here
     }
    

    EDIT : You can loaction, birthday, and many other fields listed in FBGraph API Documentation.

    Just change param dictionary in above code

     NSDictionary *param=[NSDictionary dictionaryWithObjectsAndKeys:@"picture,name,location,birthday",@"fields", nil];