我可以获取用户的信息名称,性别等,但是当我尝试访问用户的生日登录不起作用时,这是我的LoginController代码
public function redirectToProvider()
{
return Socialite::driver('facebook')->fields([
'first_name', 'last_name', 'email', 'gender', 'birthday'
])->scopes([
'email', 'user_birthday'
])->redirect();
}
/**
* Obtain the user information from GitHub.
*
* @return Response
*/
public function handleProviderCallback()
{
try
{
$facebook_user = Socialite::driver('facebook')->fields([
'first_name', 'last_name', 'email', 'gender', 'birthday'
])->scopes([
'email', 'user_birthday'
])->user();
// echo $facebook_user->getAvatar();
// this returns the data but when i try to access
// $facebook_user->user['birthday'] it doesnt give any error or login
// dd($facebook_user->user['birthday']);
$facebook_user_id = $facebook_user->getId(); // unique facebook user id
$user = User::where('facebook_user_id', $facebook_user_id)->first();
// dd($user);
if (!$user)
{
// dd($facebook_user->avatar);
$user = new User;
$user->facebook_user_id = $facebook_user_id;
$user->name = $facebook_user->getName();
$user->avatar = $facebook_user->getAvatar();
$user->email = $facebook_user->getEmail();
$user->gender = $facebook_user->user['gender'];
// $user->birthday = $facebook_user->user['birthday'];
// dd($user);
$user->save();
auth()->login($user);
return redirect('/location');
}
else
auth()->login($user);
}
return redirect('/location');
}
我希望访问更多信息,例如用户家乡,我添加了字段和范围,但它没有给出任何错误,只返回登录页面