我关注this guide
我的Laravel\Socialite\SocialiteServiceProvider
中的 config/app.php
没问题,别名也应该没问题:'Socialite' => Laravel\Socialite\Facades\Socialite::class,
这是我的代码:
配置/ services.php
'facebook' => [
'client_id' => 'xxxx',
'client_secret' => 'xxxxx',
'redirect' => 'http://localhost:8000/auth/fb',
]
路线
Route::get('auth/fb', 'FBController@redirectToProvider');
Route::get('auth/fb/callback', 'FBController@handleProviderCallback');
控制器
namespace App\Http\Controllers;
use Socialite;
use Illuminate\Routing\Controller;
class FBController extends Controller`
{
public function redirectToProvider()
{
return Socialite::driver('facebook')->redirect();
}
public function handleProviderCallback()
{
$user = Socialite::driver('facebook')->user();
}
}
但
错误 FatalErrorException in FBController.php line 14:
Class 'App\Http\Controllers\Socialite' not found
我该怎么做才能解决这个问题?
答案 0 :(得分:1)
将Socialite;
替换为use Socialize;
以及社交名称将其替换为社交名称的所有实例
namespace App\Http\Controllers;
use Socialize;
use Illuminate\Routing\Controller;
class FBController extends Controller
{
public function redirectToProvider()
{
return Socialize::driver('facebook')->redirect();
}
public function handleProviderCallback()
{
$user = Socialize::driver('facebook')->user();
}
}