我使用https://github.com/sahat/satellizer在我的angular + laravel(5.2)应用程序中添加带有facebook功能的登录。卫星导航:在登录facebook时不返回电子邮件
这里是我使用PHP中调用一个Facebook图形API
$client = new GuzzleHttp\Client();
$params = [
'code' => $request->input('code'),
'client_id' => $request->input('clientId'),
'redirect_uri' => $request->input('redirectUri'),
'client_secret' => Config::get('app.facebook_secret')
];
// Step 1. Exchange authorization code for access token.
$accessTokenResponse = $client->request('GET', 'https://graph.facebook.com/v2.5/oauth/access_token', [
'query' => $params
]);
$accessToken = json_decode($accessTokenResponse->getBody(), true);
// Step 2. Retrieve profile information about the current user.
$profileResponse = $client->request('GET', 'https://graph.facebook.com/v2.5/me', [
'query' => $accessToken
]);
$profile = json_decode($profileResponse->getBody(), true);
的代码,但它只是在回应中传回的ID和名称。我曾尝试在网址中添加ID,名称和电子邮件地址为
$profileResponse = $client->request('GET', 'https://graph.facebook.com/v2.5/me?fields=id,name,email', [
'query' => $accessToken
]);
它仍然只返回id和名称。
我也试图在Graph API Explorer中使用由上述请求返回的令牌。它显示适当的反应。
感谢
相应地更新了我的答案。我没有看到使用任何范围参数,所以我假设你没有授权的电子邮件许可。 – luschn
我已经检查过,给这个应用程序的电子邮件许可。也正如你可以看到我的问题,我也尝试添加字段来请求网址https://graph.facebook.com/v2.5/me?fields=id,name,email,但它仍然只返回id和名称 –
所以你在api资源管理器中用你自己的应用程序来试试它?你有完全相同的回应吗? – luschn