【发布时间】:2016-07-06 22:44:33
【问题描述】:
我尝试在我的 Laravel 5.1 项目中实现 https://github.com/laravel/socialite。
所以当我阅读文档时,我写道: 在services.php
'facebook' => [
'client_id' => '567898789',
'client_secret' => 'e7055b8576508b4026098d3chhh41d98',
'redirect' => 'http://domain.com/login/callback/facebook',
],
我也在 app.php 中添加:
Laravel\Socialite\SocialiteServiceProvider::class,
和别名:
'Socialite' => Laravel\Socialite\Facades\Socialite::class,
现在在 AuthController 我添加:
public function redirectToProvider()
{
return Socialite::driver('facebook')
->scopes(['scope1', 'scope2'])->redirect();
}
/**
* Obtain the user information from GitHub.
*
* @return Response
*/
public function handleProviderCallback()
{
$user = Socialite::driver('facebook')->user();
// $user->token;
}
和route.php:
//Social Login
Route::get('auth/facebook', 'Auth\AuthController@redirectToProvider');
Route::get('auth/facebook/callback', 'Auth\AuthController@handleProviderCallback');
但是现在,当我尝试访问 http://domain.com/auth/facebook 时,我得到:
Controller.php 第 269 行中的 NotFoundHttpException:控制器方法 没找到。
怎么了?我在哪里出错?如何解决这个问题?
【问题讨论】:
-
我也尝试添加这个:使用 Illuminate\Routing\Controller;
标签: php laravel authentication laravel-5.1 laravel-socialite