Search code examples
facebook-c#-sdkfacebook-fqlfql.multiquery

How to use fql.multiquery with C# SDK


I am using the facebook-c#-sdk with VB.

my code:

dim facebook As New FacebookApp()

dim queries as string=" ""2011-4-13"" : ""SELECT metric, value FROM insights WHERE object_id=173249789387842 AND metric='page_active_users' AND end_time=end_time_date('2011-4-13') AND period=period('day')"",""2011-4-14"" : ""SELECT metric, value FROM insights WHERE object_id=173249789387842 AND metric='page_active_users' AND end_time=end_time_date('2011-4-14') AND period=period('day')"""

dim oFQLResult As Object = facebook.Query(queries )

I get: Facebook.FacebookApiException: Parser error: unexpected '\' at position 0.

A single query works perfect. What is the correct way to do multiqueries?

Thanks!


Solution

  • You might want to check out these nuget packages. (Samples are in C#)

    Install-Package Facebook.Sample
    Install-Package Facebook.Sample.Dynamic
    

    Here is sample in C#.

            var query1 = "SELECT uid FROM user WHERE uid=me()";
            var query2 = "SELECT profile_url FROM user WHERE uid=me()";
    
            try
            {
                var fb = new FacebookClient(accessToken);
    
                var result = (IList<object>)fb.Query(query1, query2);
    
                var result0 = ((IDictionary<string, object>)result[0])["fql_result_set"];
                var result1 = ((IDictionary<string, object>)result[1])["fql_result_set"];
            }
            catch (FacebookApiException ex)
            {
                // Note: make sure to handle this exception.
                throw;
            }