weann / socialite by weann

Laravel wrapper around OAuth 1 & OAuth 2 libraries.
1,371
30
7
Package Data
Maintainer Username: weann
Maintainer Contact: mail@zhangjicheng.com (Jicheng Zhang)
Package Create Date: 2015-07-28
Package Last Update: 2015-07-28
Home Page:
Language: PHP
License: MIT
Last Refreshed: 2024-11-22 03:00:44
Package Statistics
Total Downloads: 1,371
Monthly Downloads: 2
Daily Downloads: 0
Total Stars: 30
Total Watchers: 7
Total Forks: 8
Total Open Issues: 1

Laravel Socialite

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);
});