Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Execute FQL query with facebook c# sdk v6.0.10

I would like to execute a FQL to retrieve all app user's friends.

In previous versions of the sdk it could be done with:

var client = new FacebookWebClient();
client.Query(String.Format("SELECT uid, name FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = {0})", me.id));

but with the version 6.0.10 I have no clue how can I do the same.

Any ideas?

like image 763
Diego Avatar asked Mar 19 '12 13:03

Diego


1 Answers

FQL

var fb = new FacebookClient("access_token");
dynamic result = fb.Get("fql", 
    new { q = "SELECT uid FROM user WHERE uid=me()" });

FQL Multi Query

var fb = new FacebookClient("access_token");
dynamic result = fb.Get("fql", new
    {
        q = new[]
                {
                    "SELECT uid from user where uid=me()",
                    "SELECT name FROM user WHERE uid=me()"
                }
    });

FQL named multi-query

var fb = new FacebookClient("access_token");
dynamic result = fb.Get("fql",
    new
        {
            q = new
            {
                id = "SELECT uid from user where uid=me()",
                name = "SELECT name FROM user WHERE uid " +
                "IN (SELECT uid FROM #id)",
            }
        });
like image 50
prabir Avatar answered Sep 22 '22 17:09

prabir