Error with FQL query with library 5.4.1

2019-02-20 18:55发布

问题:

A few months ago I developed an application to retrieve the counters of my insights Facebook pages. This application works perfectly with the library "Facebook C# SDK" version 5.0.40. Now I want to use the last library version 5.4.1 but my application no longer works. I do not understand why.

I use the following code :

       var fb = new FacebookClient(m_accessToken);

        fb.GetCompleted +=
            (o, e) =>
            {
                if (e.Error == null)
                {
                    dynamic result = e.GetResultData();

                    // e.UserState contains the 'p_date' object which caracterize the Query  
                    string response = result.ToString();
             Console.WriteLine(response);
                }
             };

         var query0 = string.Format("SELECT metric, value FROM insights WHERE object_id=" + p_pageId + " AND metric='" + p_counter + "' AND end_time=end_time_date('" + p_date + "') AND period=period('" + p_period + "')");
         fb.QueryAsync(new[] { query0 });

For example, if I make a request for the same facebook page Id, same counter, same day, same period

with library 5.0.40, i receive a response (Example for counter "page_fans":

[{"name":"query0","fql_result_set":[{"metric":"page_fans","value":"12018"}]}]

with library 5.4.1, I receive always an empty response for any request (any counter, any day, any page):

[{"name":"query0","fql_result_set":[]}]

Does anyone can help me and tell me what I need to change in my code to allow my application runs with recent versions of the "Facebook C# SDK" library.

Best regards

Christian

回答1:

As a temporary solution until this bug is fixed you can use value in seconds for end_time and one of "lifetime, day, week, days_28, month" for period...