Laravel Socialite的TVShowTime OAuth2提供者

4.1.0 2020-12-01 23:10 UTC

This package is auto-updated.

Last update: 2024-08-26 21:41:44 UTC


README

composer require socialiteproviders/tvshowtime

安装与基本使用

请参阅基本安装指南,然后按照以下特定提供者的说明进行操作。

config/services.php中添加配置

'tvshowtime' => [    
  'client_id' => env('TVSHOWTIME_CLIENT_ID'),  
  'client_secret' => env('TVSHOWTIME_CLIENT_SECRET'),  
  'redirect' => env('TVSHOWTIME_REDIRECT_URI') 
],

添加提供者事件监听器

Laravel 11+

在Laravel 11中,默认的EventServiceProvider提供者已被移除。取而代之,你可以在AppServiceProviderboot方法中使用Event外观的listen方法添加监听器。

  • 注意:除非你用自己的提供者覆盖它们,否则不需要为内置的Socialite提供者添加任何内容。
Event::listen(function (\SocialiteProviders\Manager\SocialiteWasCalled $event) {
    $event->extendSocialite('tvshowtime', \SocialiteProviders\TVShowTime\Provider::class);
});
Laravel 10或以下配置包的监听器以监听`SocialiteWasCalled`事件。

将事件添加到app/Providers/EventServiceProvider中的listen[]数组中。有关详细说明,请参阅基本安装指南

protected $listen = [
    \SocialiteProviders\Manager\SocialiteWasCalled::class => [
        // ... other providers
        \SocialiteProviders\TVShowTime\TVShowTimeExtendSocialite::class.'@handle',
    ],
];

使用方法

现在你应该能够像常规使用Socialite一样使用此提供者(假设你已经安装了外观)

return Socialite::driver('tvshowtime')->redirect();

返回的用户字段

  • id
  • 昵称
  • 头像