1

我正在使用

        $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',
    )),
  ),
))

当我明确将其添加到应用程序设置的“请求的权限”中时,为什么电子邮件权限甚至不在列表中?

4

5 回答 5

2

解决了。

不得不换

$helper->getLoginUrl();

为了

$helper->getLoginUrl(
    array(
        'scope' => 'email'
    )
);

(“范围”必须包含逗号分隔列表中的所有权限)

于 2014-05-07T23:15:06.657 回答
1

我会在这里使用图形资源管理器来查看您可以/应该返回什么:https ://developers.facebook.com/tools/explorer/

电子邮件列在扩展权限选项卡下。

您是如何登录用户的?您应该将包括“电子邮件”在内的范围传递给 getLoginUrl 方法。

于 2014-05-07T20:53:16.020 回答
1

我在 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>';
}
于 2014-09-23T14:46:51.017 回答
0

公共函数getLoginUrl($scope = array('email'), $version = null)公共函数getLoginUrl($scope = array('email'), $version = null)公共函数getLoginUrl($scope = array('email' ), $version = null)public function getLoginUrl($scope = array('email'), $version = null)public function getLoginUrl($scope = array('email'), $version = null)public function getLoginUrl($ scope = array('email'), $version = null)public function getLoginUrl($scope = array('email'), $version = null)public function getLoginUrl($scope = array('email'), $version = null)public function getLoginUrl($scope = array('email'), $version = null)public function getLoginUrl($scope = array('email'), $version = null)public function getLoginUrl($scope = array('电子邮件'),$version = null)public function getLoginUrl($scope = array('email'), $version = null)public function getLoginUrl($scope = array('email'), $version = null)

于 2015-02-16T11:15:43.807 回答
-1

看到 FacebookRedirectLoginHelper.php 中的 90 行...看起来像

公共函数 getLoginUrl($scope = array(), $version = null)

我改变

公共函数 getLoginUrl($scope = array('email'), $version = null)

和工作!

问候!!!!

于 2014-09-26T02:02:04.523 回答