Although the issue is common and might be similar but none of the solution actually worked. My code
$facebook = new Facebook\Facebook([
'app_id' => $config['fb_api'],
'app_secret' => $config['fb_secret'],
'default_graph_version' => 'v2.4',
'cookie' => false,
]);
$helper = $facebook->getRedirectLoginHelper();
try {
if (isset($_SESSION['facebook_access_token'])) {
$accessToken = $_SESSION['facebook_access_token'];
} else {
$accessToken = $helper->getAccessToken();
}
} 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;
}
But my $accessToken
variable is empty. I checked dumping the variable and found its empty. It was working properly previously. Dont know what triggered and now I am getting following error.
Uncaught exception 'Facebook\Exceptions\FacebookAuthenticationException' with message 'An active access token must be used to query information about the current user