I've been struggling with this for over a day now and I really haven't made any progress. It doesn't help that Facebook has terrible documentation and that many of the answers on StackOverflow, however useful, are out of date or have no answers.
What I am attempting to do is use Facebook's PHP SDK to generate a list of page likes, and then use that list to make a chart. I haven't figured out how I'm going to make that chart yet, but that's okay.
First I connect to Facebook with the following:

$facebook = new Facebook(array( 'appId' => $appId, 'secret' => $secret,));$user = $facebook->getUser();if (!$user) { $loginUrl = $facebook->getLoginUrl(array('scope' => 'read_insights'));}echo 'Login with Facebook';Then, I collect the information I need:

$user_profile = $facebook->api('/me');And I print the data I get back:




The $_SESSION shows me my Facebook sessions, and the $user_profile shows me things about me that I already know, like my name and pages I follow. I can use these to get my access token and my id:

$_SESSION['fb_164267460450174_access_token'];$user_profile['id'] ( or $_SESSION['fb_164267460450174_user_id'] )Now, with this data I want to do what the Facebook Graph Explorer does and get my page fans during it's lifetime from day ABC to day XYZ. The url is:

1396909270521211/insights/page_fans/lifetime?suppress_http_code=1&since=1377950400&unt il=1385467200I'm not sure how to do that, so I then find this link, and try what it says, but I then learn me/accounts is deprecated and is now me/application/developers, which I discovered here, with the official documentation here.
So, following the first link, with the new documentation, I try the following:

$pageAccessToken = $_SESSION['fb_164267460450174_access_token'];$facebook->setAccessToken($pageAccessToken);$insights = $facebook->api("/me/applications/developer/");print_r($insights);Which gives me an array of the the page name, it's id, and paging. But it doesn't give me the access token, which is demonstrated in the first link, which I need to get the page insights.
I then try to use the Facebook API Explorer access token instead, but it throws the following error:

Uncaught GraphMethodException: Invalid appsecret_proof provided in the API argument thrown in...So, I can't get the information I need. My session access token doesn't provide it, and the Facebook API Explorer token breaks it. I'm assuming my problem is that I need some kind of permission set, but I can't figure out where or what I'm doing wrong.
And, I hate to be too picky, but to the people who answer, this, can you do more than just provide a link? Possibly with an example? I've been staring at the documentation for hours and it isn't looking any clearer.
Thank you, and if you're an American, Happy Thanksgiving :)


Check Solution