Get online facebook friend list using FQL in c#

Hi,

Do you want to Get online facebook friend list using FQL in 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 online Facebook friend list using FQL in c#".

var client = new FacebookClient(lblUserToken.Text);
client.IsSecureConnection = true;

var friendListData = new Facebook.JsonObject();
try
{
    friendListData = (Facebook.JsonObject)client.Get("fql",
        new
        {
    q = new{    name = "SELECT uid, name, online_presence, status FROM user WHERE (online_presence='active' or online_presence='idle')and uid IN (SELECT uid2 FROM friend WHERE uid1 =me())"}
        });

    JObject friendListJson = JObject.Parse(friendListData.ToString());

   
    foreach (var friend in friendListJson["data"].Children().Children())
    {

        fbUser.Id = ((friend).Root["data"][0]["fql_result_set"][i]["uid"]).ToString();
        fbUser.Name = ((friend).Root["data"][0]["fql_result_set"][i]["name"]).ToString();

    }

Comments