0

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

Ninja
  • 428
  • 4
  • 17
  • Possible duplicate of [facebook Uncaught OAuthException: An active access token must be used to query information about the current user](https://stackoverflow.com/questions/6034813/facebook-uncaught-oauthexception-an-active-access-token-must-be-used-to-query-i) – Narayan Aug 08 '17 at 09:17
  • Just to note - you're using a version of the graph API (v2.4) that is over 2 years old... I'd suggest upgrading to a more recent version. Your version is only available till october 2017 - https://developers.facebook.com/docs/apps/changelog#versions – Lix Aug 08 '17 at 09:17
  • Where is the part where you send the user to the login dialog …? – CBroe Aug 08 '17 at 09:18
  • Can you please help me with the the login dialog section. I will give a try – Ninja Aug 08 '17 at 09:20
  • I used https://github.com/facebook/php-graph-sdk – Ninja Aug 08 '17 at 09:22
  • I am again having same issue. I could not get access token even after i swtich to latest graph version. – Ninja Aug 10 '17 at 02:28

0 Answers0