我正在使用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
)
感谢您的关注
答案 0 :(得分:2)
要阅读用户电子邮件,您需要相应的权限https://developers.facebook.com/docs/reference/login/#permissions
意味着您必须明确要求获得阅读权限