15/01
2018
dev-master
9999999-devThinkPHP5 Social Library
Apache-2.0
The Requires
by HWJ
Wallogit.com
2017 © Pedro Peláez
ThinkPHP5 Social Library
composer require myxland/think-social:dev-master php think social:config
1、控制器, (*1)
<?php
namespace app\index\controller;
use think\Controller;
use myxland\social\Social;
class Auth extends Controller
{
public function redirectToSocial($channel)
{
return Social::channel($channel)->redirect();
}
public function handleSocialCallback($channel)
{
$user = Social::channel($channel)->user();
// $user->getToken();
// $user->getId();
// $user->getName();
// $user->getNickname();
// $user->getAvatar();
// $user->getEmail();
}
}
2、定义路由, (*2)
Route::get('auth/:channel/callback', 'Auth/handleSocialCallback');
Route::get('auth/:channel', 'Auth/redirectToSocial');
ThinkPHP5 Social Library
Apache-2.0