socialiteproviders/twitcasting

Laravel Socialite 的 TwitCasting OAuth2 提供者

5.0.0 2022-01-26 23:13 UTC

This package is auto-updated.

Last update: 2024-08-26 21:42:47 UTC


README

composer require socialiteproviders/twitcasting

注册应用

https://en.twitcasting.tv/indexapi.php 添加新应用。

安装与基本用法

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

将配置添加到 config/services.php

'twitcasting' => [
  'client_id' => env('TWITCASTING_CLIENT_ID'),
  'client_secret' => env('TWITCASTING_CLIENT_SECRET'),
  'redirect' => env('TWITCASTING_REDIRECT_URI')
],

添加提供者事件监听器

Laravel 11+

在 Laravel 11 中,默认的 EventServiceProvider 提供者已被移除。取而代之的是,在您的 AppServiceProviderboot 方法中使用 Event 门面上的 listen 方法添加监听器。

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

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

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

用法

现在您应该能够像平时使用 Socialite 一样使用此提供者(假设您已安装门面)

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

返回的用户字段

  • id
  • nickname
  • name
  • avatar

参考