socialiteproviders / gettyimages
为 Laravel Socialite 提供的 Getty Images OAuth2 提供者
4.1.0
2020-12-01 23:10 UTC
Requires
- php: ^7.2 || ^8.0
- ext-json: *
- socialiteproviders/manager: ~4.0
This package is auto-updated.
Last update: 2024-08-26 21:31:41 UTC
README
composer require socialiteproviders/gettyimages
安装与基本使用
请参阅基础安装指南,然后按照以下特定于提供者的说明操作。
将配置添加到 config/services.php
'gettyimages' => [ 'client_id' => env('GETTYIMAGES_CLIENT_ID'), 'client_secret' => env('GETTYIMAGES_CLIENT_SECRET'), 'redirect' => env('GETTYIMAGES_REDIRECT_URI') ],
添加提供者事件监听器
Laravel 11+
在 Laravel 11 中,默认的 EventServiceProvider
提供者已被移除。取而代之的是,在您的 AppServiceProvider
的 boot
方法中使用 Event
门面上的 listen
方法添加监听器。
- 注意:除非您使用自己的提供者覆盖了内置的 Socialite 提供者,否则您不需要添加任何内容。
Event::listen(function (\SocialiteProviders\Manager\SocialiteWasCalled $event) { $event->extendSocialite('gettyimages', \SocialiteProviders\GettyImages\Provider::class); });
Laravel 10 或以下
配置包的监听器以监听 `SocialiteWasCalled` 事件。将事件添加到 app/Providers/EventServiceProvider
中的 listen[]
数组中。有关详细说明,请参阅基础安装指南。
protected $listen = [ \SocialiteProviders\Manager\SocialiteWasCalled::class => [ // ... other providers \SocialiteProviders\GettyImages\GettyImagesExtendSocialite::class.'@handle', ], ];
使用方法
现在您应该能够像通常使用 Socialite 一样使用该提供者(假设您已安装了门面)
return Socialite::driver('gettyimages')->redirect();