0

我正在使用 FB 批处理 API 进行用户登录,这是 API 调用

$queries = array(

array('method' => 'GET', 'relative_url' => '/'.$user),
array('method' => 'GET', 'relative_url' => '/'.$user.'/home?limit=50'),
array('method' => 'GET', 'relative_url' => '/'.$user.'/friends'),
array('method' => 'GET', 'relative_url' => '/'.$user.'/photos?limit=6'),

);

// POST your queries to the batch endpoint on the graph.
try{
 $batchResponse = $facebook->api('?batch='.json_encode($queries), 'POST');

 }catch(Exception $o){
 error_log($o);
}

//Return values are indexed in order of the original array, content is in ['body'] as a JSON
//string. Decode for use as a PHP array.

$user_info  = json_decode($batchResponse[0]['body'], TRUE);
$feed   = json_decode($batchResponse[1]['body'], TRUE);
$friends_list = json_decode($batchResponse[2]['body'], TRUE);
$photos   = json_decode($batchResponse[3]['body'], TRUE);

当我打印 user_info 变量时print_r($user_info),我得到了这个数组,但它没有给我用户电子邮件 ID。我不知道为什么?我浏览了文档但没有找到解决方案。如何实现这一点?
如果由于身份验证,我如何向 API 发送受信任的参数,并且身份验证仅适用于电子邮件地址而不适用于其他字段?

Array
(
[id] => 1000015567757
[name] =>Name
[first_name] => First name
[last_name] => Last name
[link] => http://www.facebook.com/sach.ch
[username] => sachtawa
[birthday] => 12/13/1987
[hometown] => Array
    (
        [id] => 1000015534545
        [name] => Patna, India
    )

[location] => Array
    (
        [id] => 106442706060302
        [name] => Pune, Maharashtra
    )

[gender] => male
[timezone] => 6
[locale] => en_US
[verified] => 1
[updated_time] => 2012-12-13T04:11:12+0000
)

感谢您的关注

4

1 回答 1

2

要阅读用户电子邮件,您需要适当的权限https://developers.facebook.com/docs/reference/login/#permissions

这意味着您必须明确要求获得阅读许可

于 2012-12-24T14:12:46.010 回答