5
votes

I would like to use graph API to get page and app insights without Facebook JS SDK. I tried the following:

  • I created an app with user A
  • I log in to that app using the following url with user B (user B is admin of pages and apps)

https://m.facebook.com/dialog/oauth?client_id=[appID]&redirect_uri=[uri]&scope=read_insights,manage_pages&response_type=token

  • Using the above url, login was ok, I got the access token
  • Using https://graph.facebook.com/me/accounts I got the list of apps and pages
  • Finally I try to query insights values with the following url https://graph.facebook.com/[page id]/insights&access_token=[login_response_access_token] but I got the following empty result:

{ "data": [ ], "paging": { "previous": "https://graph.facebook.com/[page_id]/insights?format=json&since=1329064393&until=1329323593", "next": "https://graph.facebook.com/[page_id]/insights?format=json&since=1329582793&until=1329841993" } }

What wrong with my steps? I tried to use Graph API Explorer and I cannot get insights values from the following url:

https://developers.facebook.com/tools/explorer

  1. Open above url
  2. Get access token (read_insights, manage_pages)
  3. https://graph.facebook.com/[page_id]/insights returns same empty JSON
2
I am facing the same issue. How did you resolve this?G3M

2 Answers

0
votes

I'm presuming you have the correct access_token (which is probably the case given you ability to query the objectids). Does the objectid in question have data in the last month? Also, I would recommend supplying a date range (with the since and until parameters), this has caused me issues in the past.

0
votes

your first and second steps are true but the third one is wrong because in the url https://graph.facebook.com/[page_id]/insight there is no insight field on the node of your page_id like everyone I think. You can see the fields you are able to use on the right side of the Graph explorer.

May be the reason of the emptiness of insights could be FB.api returns empty datas for some days nowadays. you can test it by clicking show old insights in the page of your app. you will see.