5

I am having issues figuring out how to get data from the graph api insights, I dont have sufficient rights to get any data returned. In the Graph API explorer I generated a new access token with the right to read insights but I dont know how to take it into use in php. I am currently trying to get the data as follows:

FacebookSession::setDefaultApplication('app_id', 'app_secret');
$session = FacebookSession::newAppSession();
$engagement = (new FacebookRequest(
    $session, 'GET', '/page_id/insights/page_engaged_users'
))->execute()->getGraphObject();
  • 1
    Rasmus, can you elaborate exact issue that you're facing. Are you facing issues with Facebook api permissions for insights. Or values in $engagement variable. You can still login with the same account that you used to set up Facebook app and check. This will fetch your accounts insight values. Hope this link helps: https://developers.facebook.com/docs/graph-api/reference/v2.3/insights – jones Jul 01 '15 at 12:59
  • Also you could use tools such as https://developers.facebook.com/tools/explorer/ to query and fetch the details that you need. – jones Jul 01 '15 at 13:06
  • I have used the explorer and I have gotten it to work. The issue it, insights require an access token with "read_insights" permission, which I do not know how to get with the php sdk. – Rasmus Nørskov Jul 01 '15 at 14:17
  • 2
    Rasmus, I hope this tutorial will answer your issues, https://www.sammyk.me/access-token-handling-best-practices-in-facebook-php-sdk-v4 If you still face issues, please let us know what you've tried so far, or any error message that you got... – jones Jul 02 '15 at 04:58
  • Wonderful tutorial learned all I needed, thank you very much. Please make an answer so I cant accept it. – Rasmus Nørskov Jul 02 '15 at 12:15

1 Answers1

1

Hope this helps others too.... regarding Facebook access token and also in query How to handle access tokens with Facebook SDK v4.0 by Sammy Kaye Powers

Community
  • 1
  • 1
jones
  • 749
  • 7
  • 34