我用
$request = new FacebookRequest($session, 'GET', '/me');
$response = $request->execute();
$graphObject = $response->getGraphObject();
在我的应用程序上访问我的个人资料数据(我已经接受了应用程序的特定请求,允许获得我的主要电子邮件地址)
我在回复中没有收到任何电子邮件字段。不过,它适用于我创建的任何测试用户。我错过了什么?
更奇怪的是:当我运行 $request = new FacebookRequest($session, 'GET', '/me/permissions');
$response = $request->execute();
$graphObject = $response->getGraphObject();
var_export($graphObject);
我:
Facebook'GraphObject::__set_state(array(
'backingData' =>
array (
0 =>
stdClass::__set_state(array(
'permission' => 'public_profile',
'status' => 'granted',
)),
),
))
为什么电子邮件权限甚至不在列表中,当我明确地将其添加到应用程序设置的"请求权限"中时?
已解决。
Had to switch
$helper->getLoginUrl();
$helper->getLoginUrl(
array(
'scope' => 'email'
)
);
('scope'必须包含逗号分隔列表上的所有权限)
我会在这里使用图形资源管理器来查看您可以/应该返回的内容:https://developers.facebook.com/tools/explorer/
email列在扩展权限选项卡下。
您如何登录用户?你应该把包括'email'在内的作用域传递给getLoginUrl方法
我在SDK 4-dev中做了这样的事情,并且正在工作
//permissions request
$request = new 'Facebook'FacebookRequest(
$session,
'GET',
'/me/permissions'
);
$response = $request->execute();
$graphObjectPermissions = $response->getGraphObject()->asArray();
//echo '<pre>' . print_r( $graphObjectPermissions,1 ) . '</pre>';
$permissions = [];//create permissions array
foreach ($graphObjectPermissions as $key => $permObject) {
$permissions[$permObject->permission] = $permObject->status;
}
//check for email permission
if (array_key_exists('email', $permissions ) && $permissions['email']=='granted') {
echo '<pre> email permission granted </pre>';
} else {
echo '<pre> email Permission denied </pre>';
}
公共函数getLoginUrl($scope = array('email'), $version = null)公共函数getLoginUrl($scope = array('email'), $version = null)公共函数getLoginUrl($scope = array('email'), $version = null)公共函数getLoginUrl($scope = array('email'), $version = null)公共函数getLoginUrl($scope = array('email'), $version = null)公共函数getLoginUrl($scope = array('email'), $version = null)公共函数getLoginUrl($scope = array('email'), $version = null)公共函数getLoginUrl($scope = array('email'), $version = null)公共函数getLoginUrl($scope = array('email'), $version = null)公共函数getLoginUrl($scope = array('email'), $version = null)$version = null公共函数getLoginUrl($scope = array('email'), $version = null)公共函数getLoginUrl($scope = array('email'), $version = null)公共函数getLoginUrl($scope = array('email'), $version = null)公共函数getLoginUrl($scope = array('email'), $version = null)公共函数getLoginUrl($scope = array('email'), $version = null)公共函数getLoginUrl($scope = array('email'), $version = null)
见FacebookRedirectLoginHelper.php中的90行…它看起来像
公共函数getLoginUrl($scope = array(), $version = null)
I改变为
getLoginUrl($scope = array('email'), $version = null)
和工作! !
的问候! !