myxland/think-social

ThinkPHP5 社交库

安装次数: 8

依赖项: 0

建议者: 0

安全: 0

星标: 0

关注者: 1

分支: 0

公开问题: 0

类型:think-extend

dev-master 2018-01-15 11:33 UTC

This package is not auto-updated.

Last update: 2024-09-29 06:36:06 UTC


README

安装

composer require myxland/think-social:dev-master
php think social:config

用法

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、定义路由

Route::get('auth/:channel/callback', 'Auth/handleSocialCallback');
Route::get('auth/:channel', 'Auth/redirectToSocial');