I get the error "Graph returned an error: Invalid OAuth access token" even if I set the appId, appSecret, accesstoken correctly. And yes, the token is set in the Facebook Developer page.
<?php
session_start();
require_once ('data/Facebook/autoload.php');
$fb = new Facebook\Facebook([
'app_id' => 'xxxxxxxxxxx',
'app_secret' => 'xxxxxxxxxxxx',
'default_graph_version' => 'v2.5'
]);
try {
$response = $fb->get('/me','xxxxxxxxxxx');
}
catch(Facebook\Exceptions\FacebookResponseException $e)
{
// When Graph returns an error
echo 'Graph returned an error: ' . $e->getMessage();
exit;
}
catch(Facebook\Exceptions\FacebookSDKException $e)
{
// When validation fails or other local issues
echo 'Facebook SDK returned an error: ' . $e->getMessage();
exit;
}
$me = $response->getGraphUser();
echo 'Logged in as ' . $me->getName();
?>