这就是我致电login-callback.php
的方式:
$permissions = ['email', 'user_likes', 'user_hometown'];
$helper = $fb->getRedirectLoginHelper();
$loginUrl = $helper->getLoginUrl('http://localhost:1234/fbtest/login-callback.php', $permissions);
echo '<a href="' . $loginUrl . '">Log in with Facebook!</a>';
这是我在login-callback.php
内的登录操作:
if (isset($accessToken)) {
// Logged in!
$_SESSION['facebook_access_token'] = (string) $accessToken;
$response = $fb->get('/me');
$userNode = $response->getGraphUser();
print_r($userNode);
echo 'data: ' . $userNode['name'];
echo '<br>';
}
输出如下:
Facebook\GraphNodes\GraphUser Object ( [items:protected] => Array ( [name] => xxxNAMExxx [id] => XXXXNUMBERSXXXXX ) )
和data: xxxNAMExxx
(我显然隐藏了我的身份证和真实姓名)
问题:为什么我的email
数组中没有user_hometown
或$userNode
这样的内容,即使我在$permissions
数组中指定了name
{1}}(ref)?我可以获得id
因为它的设置,但除此之外School
,还有其他内容......
我错过了什么吗?
答案 0 :(得分:1)
您在API调用中缺少声明性字段:
<context-param>
<param-name>javax.faces.FACELETS_REFRESH_PERIOD</param-name>
<param-value>1</param-value>
</context-param>
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
更多信息:https://developers.facebook.com/docs/apps/changelog#v2_4