0

Possible Duplicate:
Graph API - get the Friends of my friend

how to get the list of friend's friend from Facebook in c# .net or in java script. I am able to get the friend list with this method :--

string data = FaceBookConnect.Fetch(code, "me/friends");

but I have no idea how to fetch friend's friend. I am also getting the my friend's Facebook id.Is there any way to fetch my friend's friend with his Facebook id?

Community
  • 1
  • 1

1 Answers1

1
string myAccessToken = "something";         
FacebookClient client = new FacebookClient(myAccessToken);         

var friendListData = client.Get("/me/friends");
JObject friendListJson = JObject.Parse(friendListData); 

ArrayList<FbUser> fbUsers = New ArrayList<FbUser>();
foreach (var friend in friendListJson["data"].Children())             
{   
    FbUser fbUser = new FbUser();
    fbUser.Id = friend["id"].ToString().Replace("\"", "");                 
    fbUser.Name = friend["name"].ToString().Replace("\"", "");                 
    fbUsers.add(fbUser);
}

Class for facebook user

Class FbUser {
    String Id { set; get; }
    String Name { set; get; }
}

Facebook SDK C# - get friends list

EDIT: You can't get friends of a friend:

Get the Friends of my friend using the Graph API

{
   "error": {
      "type": "Exception",
      "message": "(#604) Can't lookup all friends of <UID>. Can only lookup for the logged in user (<MY_UID>), or friends of the logged in user with the appropriate permission"
   }
}
Community
  • 1
  • 1
Carlos Landeras
  • 10,594
  • 11
  • 51
  • 81