rubyfacebookfacebook-fql

Facebook FQL returns <fql_query_response list="true"/>


I am trying to get a facebook fql query to work using the browser, I have a valid oauth token (I can make graph api calls with it).

Here is the url I tried:

https://api.facebook.com/method/fql.query?query=SELECT metric, value FROM insights WHERE object_id=89192912655 AND end_time=1280430050 AND period=86400 AND metric='page_fans'&access_token=?

I also tried running the fql query through a sql encoder first:

https://api.facebook.com/method/fql.query?query=SELECT%20metric%2C%20value%20FROM%20insights%20WHERE%20object_id%3D89192912655%20AND%20end_time%3D1280430050%20AND%20period%3D86400%20AND%20metric%3D'page_fans'&access_token=?

I tried a few other metrics, I can get the metrics via the graph api as well, so I know they are there.

Im sure im doing something dumb, but I have been stumped on this for a while now! Every call just returns this:

<?xml version="1.0" encoding="UTF-8"?>
<fql_query_response xmlns="http://api.facebook.com/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" list="true"/>

Maybe my dates are a problem, I used this to get the date: (ruby)

t = Time.now
=> Tue Aug 03 15:00:50 -0400 2010
>> t = t - 5.days
=> Thu Jul 29 15:00:50 -0400 2010
>> t.to_i
=> 1280430050

any ideas?


Solution

  • We have confirmed this bug. This is due to the end_time having to be aligned with day delimiters in PST in order for the Insights table to return any data. To address this issue, we introduced two custom functions you can use to query the insights table:

    1. end_time_date() : accept DATE in string form(e.g. '2010-08-01')
    2. period() : accept 'lifetime', 'day', 'week' and 'month'

    For example, you can now query the insights table using:

    SELECT metric, value FROM insights
    WHERE object_id = YOUR_APP_ID AND
          metric = 'application_active_users' AND
          end_time = end_time_date('2010-09-01') AND
          period = period('day');
    

    We will document about these functions soon, sorry for all the inconvenience!

    P.S. If you don't want to use the end_time_date() function, please make sure the end_time timestamp in your query is aligned with day delimiters in PST.

    Thanks!

    Facebook Insights Team