facebookfacebook-graph-apifacebook-insights

How to get results from Facebook Insights API


I'm trying to get useful data from the Insights section using the the Graph API Explorer.

I've tried different metrics and dates, and the results for data is always empty.

I was able to look at my page dashboard for number of likes and select a range based on that, but I still don't see any data.

If the access_key is an issue, would it return an error saying so, or just return empty results?

Here is the debug output from a popular company that I would imagine has new likes in the past few weeks.

=== Query
  curl -i -X GET \
   "https://graph.facebook.com/v2.8/14226545351/insights/page_positive_feedback_by_type?since=1487788679&until=1490812690&access_token=<access token sanitized>"
=== Access Token Info
  {
    "perms": [
      "user_likes",
      "manage_pages",
      "pages_show_list",
      "public_profile"
    ],
    "page_id": 167544343274096,
    "user_id": "10152810337959467",
    "app_id": 145634995501895
  }
=== Parameters
- Query Parameters

  {
    "since": "1487788679",
    "until": "1490812690"
  }
- POST Parameters

  {}
=== Response
  {
    "data": [],
    "paging": {
      "previous": "https://graph.facebook.com/v2.8/14226545351/insights?access_token=<access token sanitized>&pretty=0&since=1484764668&until=1487788679&metric=page_positive_feedback_by_type",
      "next": "https://graph.facebook.com/v2.8/14226545351/insights?access_token=<access token sanitized>&pretty=0&since=1490812690&until=1493836701&metric=page_positive_feedback_by_type"
    },
    "__debug__": {}
  }
=== Debug Information from Graph API Explorer
- https://developers.facebook.com/tools/explorer/145634995501895/?method=GET&path=14226545351%2Finsights%2Fpage_positive_feedback_by_type%3Fsince%3D1487788679%26until%3D1490812690&version=v2.8

Is anyone able to give an actual working example? I have not come across any yet.


Solution

  • I discovered in the Graph API explorer, when you generate an access token, you need to give it permission "read_insights".

    Also, this will only work on a page which your account has access to that given object.

    Unfortunately the documentation is pretty vague in this area and there was no permissions error message give.