Here's the modified code to get Friends of Friends but tis by default does not work and raises the following error
{
"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"
}
}
The reason is that unless the friend has allowed APPs to access his friends of friends, it will not work
{
FaceBookConnect.API_Key = "Key";
FaceBookConnect.API_Secret = "Secret";
if (!IsPostBack)
{
string code = Request.QueryString["code"];
if (!string.IsNullOrEmpty(code))
{
string data = FaceBookConnect.Fetch(code, "me/friends");
FaceBookData facebookData = new JavaScriptSerializer().Deserialize<FaceBookData>(data);
foreach (FaceBookUser user in facebookData.Data)
{
user.PictureUrl = string.Format("https://graph.facebook.com/{0}/picture", user.Id);
}
FaceBookUser friend1 = facebookData.Data[0];
data = FaceBookConnect.Fetch(code, friend1.Id + "/friends");
facebookData = new JavaScriptSerializer().Deserialize<FaceBookData>(data);
gvFriends.DataSource = facebookData.Data;
gvFriends.DataBind();
}
}
}
protected void btnFetch_Click(object sender, EventArgs e)
{
FaceBookConnect.Authorize("user_photos,friends_photos", Request.Url.AbsoluteUri);
}