我按照文档编写了login_callback.php https://developers.facebook.com/docs/php/howto/example_facebook_login
$fb = new Facebook\Facebook([
'app_id' => '{app-id}', // Replace {app-id} with your app id
'app_secret' => '{app-secret}',
'default_graph_version' => 'v2.2',
]);
$helper = $fb->getRedirectLoginHelper();
try {
$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;
}
但我的代码将停留在这一行:
$accessToken = $helper->getAccessToken();
代码停止,不要跳转到捕获异常。 然而,在我刷新页面后,我得到了[此授权代码]。