美好的一天!
所以我用我的瘦身框架应用尝试facebook php sdk v4,当我点击我的登录链接时,我得到了这个:
如您所见,它没有返回任何错误。
我的按钮登录链接代码
<a href="/loginwithfb" class="btn btn-primary btn-sm">
<i class="fa fa-facebook-square"></i>
Login
</a>
我的路线:
$app->get('/loginwithfb', 'AuthController::fblogin');
我的AuthController:
public static function fblogin() {
$fb = new Facebook\Facebook([
'app_id' => '{}',
'app_secret' => '{}',
'default_graph_version' => 'v2.5',
//'default_access_token' => '{access-token}', // optional
]);
// Use one of the helper classes to get a Facebook\Authentication\AccessToken entity.
// $helper = $fb->getRedirectLoginHelper();
// $helper = $fb->getJavaScriptHelper();
// $helper = $fb->getCanvasHelper();
// $helper = $fb->getPageTabHelper();
try {
// Get the Facebook\GraphNodes\GraphUser object for the current user.
// If you provided a 'default_access_token', the '{access-token}' is optional.
$response = $fb->get('/me', '{access-token}');
} 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();
}
我通过作曲家安装了facebook php sdk。
我在这里错过了什么吗?