Get facebook friend list using c#

Hi,

Do you want to get your friend list from Facebook using c#?

Please follow the steps as following :

[Ignore this step if you have created application in Facebook and done with login  functionality]
Step 1 : Create application into Facebook, Login using javascript and get access token :
http://narendrajarad.blogspot.in/2014/07/facebook-login-using-javascript.html

[Ignore this step if you have already add reference of Facebook from Nuget packages to your project]
Step 2 : Add reference of Facebook to your project :
http://narendrajarad.blogspot.in/2014/07/add-reference-of-facebook-from-nuget-to.html

Finally use this below code to "Get Facebook friend list using c#":

string myAccessToken = hdfAccessToken.Value;
FacebookClient client = new FacebookClient(myAccessToken);

var friendData = client.Get("/me/friends");
JObject friendList = JObject.Parse(friendData.ToString());

foreach (var friend in friendList["data"].Children())
{
Response.Write(friend["id"].ToString().Replace("\"", ""));
Response.Write(fbUser.Name = friend["name"].ToString().Replace("\"", ""));
}

Comments