I am trying to build an analytics dashboard and get the page views, engagements, and reach for a Facebook page. I haven't found a way to access read_insights on the graph api with our app and admin user (see this question: Facebook (#100) Tried accessing nonexisting field (read_insights) on node type (Page)), but I have been able to directly access some information using file_get_contents and running a url through it. I know that this one works:
https://graph.facebook.com/{page_id}/feed?access_token={access_token}
With that call I get arrayed data of the recent posts.
I have run this URL to get insights page_views_total:
https://graph.facebook.com/{page_id}/insights/page_views_total?access_token={access_token}
but I only get back an array
{
"data": [
],
"paging": {
"previous": "https://graph.facebook.com/v2.9/{page_id}/insights?access_token={token_string}\{access_string}w&pretty=1&metric=page_views_total&since=1497596400&until=1497769200",
"next": "https://graph.facebook.com/v2.9/{page_id}/insights?access_token={token_string}\{access_string}&pretty=1&metric=page_views_total&since=1497942000&until=1498114800"
}
}
Which none of these arrays have any useful information. I've tried running the enclosed URLs in the arrays but it just gives Oauth errors.
The way I got this URL initially was following these steps and replacing feed with insights/{metric_data}
"Go to https://developers.facebook.com/tools/access_token/ . When you copy it, you just go directly https://graph.facebook.com//feed?access_token="
Side note: The Facebook Graph API is rather difficult to interpret for newbies so I have put aside the authentication and token methods in PHP and am trying to get a direct URL for my data. Probably not the best solution but I can't figure out how to get authenticated with my app and extract the page insights data.