Andrew
Andrew

Reputation: 716

Facebook Insights API is returning no data (empty array) for a post

My application is pulling back a few insights statistics. This works fine for my FB account, which I used to develop the feature, but my users get an empty array, ex:

{
    "data": [],
    "paging": {...}
}

I obtain authorization via OAuth and I've asked for the read_insights permission. I can verify it has been granted in the list of permissions

https://graph.facebook.com/me/permissions?access_token=XXX

{
   "data": [
      {
         "installed": 1,
         "basic_info": 1,
         "public_profile": 1,
         "read_stream": 1,
         "status_update": 1,
         "photo_upload": 1,
         "video_upload": 1,
         "create_note": 1,
         "share_item": 1,
         "export_stream": 1,
         "publish_stream": 1,
         "read_insights": 1,
         "manage_pages": 1,
         "publish_actions": 1,
         "user_friends": 1
      }
   ],
   "paging": {...}
}

I know the post is valid since I can request it with the graph api

https://graph.facebook.com/[post id]?access_token=XXX

Also, the account meets the > 30 followers requirement for Insights

Update

I can get insights for all posts except those generated by my application. The only difference between posts generated by my app and facebook are:

Facebook has

"privacy": {
      "description": "Public",
      "value": "EVERYONE",
      "friends": "",
      "networks": "",
      "allow": "",
      "deny": ""
   },

   "status_type": "shared_story",

Mine has

"privacy": {
      "value": ""
   },

   "status_type": "app_created_story",
   "application": {
      "name": "Company",
      "id": "1111111111111"
   },

However I was able to get insights on a Facebook generated status that has privacy:

privacy: {
value: ""
},

So only difference now is "application" and "status_type".

Upvotes: 2

Views: 4802

Answers (2)

Beto Castillo
Beto Castillo

Reputation: 867

We had a similar problem, we were able to solve it, it's mostly a mismatch of accesses: just follow the following steps:

  1. Add the user (developer) profile to the company facebook page as an advertiser.
  2. Also, add the same account on the Facebook Bussiness manager as an advertiser.
  3. And then you will receive an email from facebook to confirm the granted accesses. Confirm them , all done. Now you have all the needed access at the right place.

Lastly, you can test again https://graph.facebook.com/v2.7/XXXXXXXXXXXXXXX/insights/ where XXXXXXXXXXX is the Company Ads' Id

Upvotes: 0

Andrew
Andrew

Reputation: 716

I was using the facebook js sdk to post. If I use server api post I can get insights so looks to me like a Facebook bug

Upvotes: 3

Related Questions