Home  >  Article  >  Backend Development  >  Laravel 第三方登录,支持微信、QQ

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

WBOY
WBOYOriginal
2016-06-20 12:51:461689browse

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

项目主页:http://www.open-open.com/lib/view/home/1438146894410

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn