承接 winkylink/socialite 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

winkylink/socialite

最新稳定版本:5.4

Composer 安装命令:

composer require winkylink/socialite

包简介

Socialite Provider for WinkyLink

README 文档

README

Author: WinkyLink.com

1. Create your application in https://winkylink.com

2. Get your Client Id and Client Secret code

3. Register plugin in your AppServiceProvider

public function boot(): void
    {
        try {
            $socialite = $this->app->make(Factory::class);
            $socialite->extend('winkylink', static function () use ($socialite) {
                return $socialite->buildProvider(SocialiteWinkyLinkProvider::class, config('services.winkylink'));
            });
        } catch (BindingResolutionException $e) {
        }
    }

4. Add config in your config/service.php

'winkylink' => [
    'client_id' => '',
    'client_secret' => '',
    'redirect' => env('APP_URL', '').'/callback/winkylink',
],

5. Create your routes

Route::get('auth/redirect/{provider}', 'SocialController@redirect');
Route::get('callback/{provider}', 'SocialController@callback');

6. Create your controller like this

class SocialController extends BaseController
{
    /**
     * @param string $provider
     * @return RedirectResponse
     */
    public function redirect(string $provider): RedirectResponse
    {
        return Socialite::driver($provider)->redirect();
    }

    /**
     * @param string $provider
     * @return RedirectResponse
     */
    public function callback(string $provider): RedirectResponse
    {
        try {
            $getInfo = Socialite::driver($provider)->user();
            $user = $this->createUser($getInfo, $provider);
            auth()->login($user);
            return redirect()->route('index');
        } catch (Throwable $e) {
            return redirect('auth/redirect/' . $provider);
        }
    }
    
    /**
     * @param mixed $getInfo
     * @param string $provider
     * @return User
     */
    private function createUser($getInfo, string $provider): User
    {
        // Create your user model using $getInfo array
         return $user;
    }
    
}

7. Add to your blade login button like this

<a href="https://yourwebsite.com/auth/redirect/winkylink">Login with WinkyLink</a>

统计信息

  • 总下载量: 85
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: proprietary
  • 更新时间: 2022-08-02