使用Laravel Socialite进行Facebook注册和登录

问题描述 投票:0回答:1

[当我尝试将Laravel Socialite与Facebook API登录系统一起使用时,在注册过程中出现错误。

消息:

Symfony\Component\Debug\Exception\FatalThrowableError
Call to undefined method Laravel\Socialite\Two\FacebookProvider::getId()

C:\xampp\htdocs\socialite\app\Http\Controllers\Auth\SocialiteController.php:36

这是第36行的代码:

$SocialAccount = SocialAccount::where('provider_id', $socialUser->getId())
                            ->where('provider_name', $provider)
                            ->first(); 
php laravel laravel-socialite
1个回答
0
投票

首先您需要通过下面的代码获得用户

$socialiteUser = Socialite::driver($provider)->user();

然后您可以调用getId函数

$socialiteUser->getId()
© www.soinside.com 2019 - 2024. All rights reserved.