Laravel Facebook登录/丢失电子邮件 [英] Laravel Facebook-Login / missing email
问题描述
我正在尝试在Laravel应用程序中创建一个Facebook登录.但是,即使我已经请求获得接收电子邮件的权限,我获得的包含所有用户信息的数组也不包含用户的电子邮件.
I am trying to create a Facebook-Login in my Laravel application. However, the array I get with all the user information does not contain the users email even though I already ask for permission to receive the email.
这是我的代码:
Route::get('login/fb', function() {
$facebook = new Facebook(Config::get('facebook'));
$params = array(
'redirect_uri' => url('/login/fb/callback'),
'scope' => 'email',
);
return Redirect::to($facebook->getLoginUrl($params));
});
Route::get('login/fb/callback', function() {
$code = Input::get('code');
if (strlen($code) == 0) return Redirect::to('/')->with('message', 'There was an error communicating with Facebook');
$facebook = new Facebook(Config::get('facebook'));
$me = $facebook->api('/me');
return $me;
返回$ me会给我除电子邮件地址之外的所有重要用户信息.
Returning $me gives me all the important user information besides the email address.
有什么办法可以解决这个问题?
Is there any way to fix this?
任何帮助将不胜感激.
谢谢.
推荐答案
在某些情况下,facebook将不会返回电子邮件.这可能是因为用户尚未设置主电子邮件,或者他们的电子邮件尚未经过验证.在这种情况下,您的逻辑应检查是否已返回电子邮件,否则请使用其Facebook电子邮件. FacebookUsername@facebook.com
There are instances that facebook will not return an email. This can be because the user has not set a primary email, or their email has not been validated. In this case, your logic should check to see if an email was returned, if not, use their facebook email. FacebookUsername@facebook.com
这篇关于Laravel Facebook登录/丢失电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!