2

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".

serenesat
  • 4,611
  • 10
  • 37
  • 53
Andrew
  • 716
  • 1
  • 8
  • 19
  • Are you using the correct access token for the page whose insights you're trying to access? – Igy Jan 15 '14 at 19:10
  • I'm only aware of one access token. I'm using the access_token that is returned from oauth. I use this access token with other graph api calls successfully. – Andrew Jan 15 '14 at 19:28
  • Yes, but does the user you're logged in as when you perform the OAuth process have permission to access the insights of the page you're trying to access? – Igy Jan 15 '14 at 20:34
  • Instead of normal access_token try to get long lived access_token, and use it in your code, this link will be helpful for you to get longer access_token - http://stackoverflow.com/questions/10467272/get-long-live-access-token-from-facebook – Vishwesh Shetty Jan 16 '14 at 04:36
  • @Igy How do I determine if the user has permission to access the insights? The query for pages [https://graph.facebook.com/me/accounts] returns the following for the page that contains the post "perms": [ "ADMINISTER", "EDIT_PROFILE", "CREATE_CONTENT", "MODERATE_CONTENT", "CREATE_ADS", "BASIC_ADMIN" ], – Andrew Jan 16 '14 at 17:07
  • @VishweshShetty The token is valid and long lived. I can use it with other api calls – Andrew Jan 16 '14 at 17:08
  • i have used the loglivetoken but the insights data is empty. idea please – EL missaoui habib Jul 05 '16 at 22:09

2 Answers2

3

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

Andrew
  • 716
  • 1
  • 8
  • 19
0

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

Beto Castillo
  • 867
  • 9
  • 16