Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook Graph API - Object Insights Returning No Data

I am getting a response with an empty data array for most if not all of the object insight Facebook API calls. I am requesting the following permissions when logging in: read_insights, publish_pages, manage_pages.

some requests I am trying to make include: page_views_total, page_impressions, page_fans

FB.api(
      "/1493689654199431/insights/page_impressions/lifetime",
      function (response) {
        if (response && !response.error) {
          console.log(response);
        }
      }
  );

Response example:

{
  "data": [
  ],
  "paging": {
    "previous": "https://graph.facebook.com/v2.6/1493689654199431/insights/page_impressions/lifetime?access_token=EAACEdEose0cBAGNO4tT95osm9KIaLlsoxoWPyk7g4J6m3iBwa5ZArxGEZBbeIpILExuTZAC6KFRHfCuccbsOCCQLmRZCItZAAmTs3PXzueCCJ0CVjr6UBB3gZCfClQeeI1PbHZCnJVqZBPHf00Vl6U4Lj6B1FpMhZAqUSdXNvcPDWlAZDZD&debug=all&format=json&method=get&pretty=0&suppress_http_code=1&since=1462194002&until=1462453202",
    "next": "https://graph.facebook.com/v2.6/1493689654199431/insights/page_impressions/lifetime?access_token=EAACEdEose0cBAGNO4tT95osm9KIaLlsoxoWPyk7g4J6m3iBwa5ZArxGEZBbeIpILExuTZAC6KFRHfCuccbsOCCQLmRZCItZAAmTs3PXzueCCJ0CVjr6UBB3gZCfClQeeI1PbHZCnJVqZBPHf00Vl6U4Lj6B1FpMhZAqUSdXNvcPDWlAZDZD&debug=all&format=json&method=get&pretty=0&suppress_http_code=1&since=1462712402&until=1462971602"
  }
}
like image 585
jrock89 Avatar asked Mar 06 '26 02:03

jrock89


1 Answers

The JavaScript SDK uses a User Token by default, you need to get and use a Page token for Page Insights. You get a Page Token with the /me/accounts endpoint, and this is how you can use it:

FB.api(
    "/1493689654199431/insights/page_impressions/lifetime",
    {access_token: pageToken},
    function (response) {
        if (response && !response.error) {
            console.log(response);
        }
    }
);

You can debug your Page Token here: https://developers.facebook.com/tools/debug/accesstoken/

like image 115
andyrandy Avatar answered Mar 08 '26 00:03

andyrandy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!