請求大大指點迷津:
我從某範例中學到了加入 socialiteproviders/QQ的方法,但我需要的是Line,經如QQ方法泡製後得到結論如下:
於是網路爬文以及@firecold 大大的提醒找到了說明文:https://socialiteproviders.netlify.com/providers/line.html
經按照說明文指示設置步驟如下:
composer require socialiteproviders/line
...
class EventServiceProvider extends ServiceProvider
{
/**
* The event listener mappings for the application.
*
* @var array
*/
protected $listen = [
Registered::class => [
SendEmailVerificationNotification::class,
],
'SocialiteProviders\Manager\SocialiteWasCalled' => [
'SocialiteProviders\QQ\QqExtendSocialite@handle',
],
\SocialiteProviders\Manager\SocialiteWasCalled::class => [
// add your listeners (aka providers) here
'SocialiteProviders\\Line\\LineExtendSocialite@handle',
],
];
...
Line_KEY=164*****708
Line_SECRET=790f651*******ffb****80
Line_REDIRECT_URI=http://localhost:8000/auth/Line/callback
....
'Line' => [
'client_id' => env('Line_KEY'),
'client_secret' => env('Line_SECRET'),
'redirect' => env('Line_REDIRECT_URI'),
],
....
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Socialite;
class SocialitesLineController extends Controller
{
//跳转到Line授权页面
public function line()
{
return Socialite::with('line')->redirect();
}
//用户授权后,跳转回来
public function callback()
{
$info = Socialite::driver('line')->user();
dump($info);
}
}
Route::namespace('Auth')->prefix('auth/line')->group(function () {
Route::get('/', 'SocialitesLineController@line');
Route::get('callback', 'SocialitesLineController@callback');
});
求解!希望有大大指點,謝謝!