weann/socialite

Laravel wrapper around OAuth 1 & OAuth 2 libraries.

v1.0 2015-07-28 15:01 UTC

This package is not auto-updated.

Last update: 2024-11-13 09:48:18 UTC


README

Laravel 第三方登录,支持微信、QQ。

安装

使用 composer 命令

composer require weann/socialite

注册服务提供者

Weann\Socialite\SocialiteServiceProvider::class,

注册 Facade

'Socialite' => Weann\Socialite\Facades\Socialite::class,

使用

配置文件 config/services.php

'wechat' => [
    'client_id' => 'APP_ID',
    'client_secret' => 'APP_SECRET',
    'redirect' => 'CALLBACK_URL'
],

将用户重定向到授权页面。

Route::get('/', function () {
    return Socialite::driver('wechat')->redirect();
});

授权后的回调。

Route::get('callback', function () {
    $user = Socialite::driver('wechat')->user()
    dd($user);
});