VKontakte
5.0.0
composer require socialiteproviders/vkontakte
在 vk.com 添加新应用程序。
请参阅基本安装指南,然后按照下面的提供商特定说明进行操作。
config/services.php
' vkontakte ' => [
' client_id ' => env ( ' VKONTAKTE_CLIENT_ID ' ),
' client_secret ' => env ( ' VKONTAKTE_CLIENT_SECRET ' ),
' redirect ' => env ( ' VKONTAKTE_REDIRECT_URI ' )
],
在 Laravel 11 中,默认的EventServiceProvider
提供程序已被删除。相反,请在AppServiceProvider
boot
方法中使用Event
外观上的listen
方法添加侦听器。
Event :: listen ( function ( SocialiteProviders Manager SocialiteWasCalled $ event ) {
$ event -> extendSocialite ( ' vkontakte ' , SocialiteProviders VKontakte Provider ::class);
});
将事件添加到app/Providers/EventServiceProvider
中的listen[]
数组中。有关详细说明,请参阅基本安装指南。
protected $ listen = [
SocialiteProviders Manager SocialiteWasCalled ::class => [
// ... other providers
SocialiteProviders VKontakte VKontakteExtendSocialite ::class. ' @handle ' ,
],
];
您现在应该能够像定期使用 Socialite 一样使用该提供程序(假设您已安装了外观):
return Socialite :: driver ( ' vkontakte ' )-> redirect ();
id
nickname
name
email
avatar