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

WBOY
Release: 2016-06-20 12:51:46
Original
1689 people have browsed it

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

安装

使用 composer 命令

composer require weann/socialite
Copy after login

注册服务提供者

Weann\Socialite\SocialiteServiceProvider::class,
Copy after login

注册Facade

'Socialite' => Weann\Socialite\Facades\Socialite::class,
Copy after login

使用

配置文件config/services.php

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

将用户重定向到授权页面。
Route::get('/', function () {    return Socialite::driver('wechat')->redirect();});
Copy after login

授权后的回调。

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

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

source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!