1 Unstar Star 4 Fork 0

chenyun / yiban

Create your Gitee Account
Explore and code with more than 5 million developers,Free private repositories !:)
Sign up
This repository doesn't specify license. Without author's permission, this code is only for learning and cannot be used for other purposes.
composer 易班API的SDK 2.0 thinkphp5 spread retract

Clone or download
chenyun authored v2.0
Cancel
Notice: Creating folder will generate an empty file .keep, because not support in Git
Loading...
README.md

绵师易班thinkphp5框架专用 SDK1.0

1 构建方式

composer require likecy/yiban:dev-master

2 使用方式

完成初始化后,通过
use likecy/yiban/YBOpenApi;

YBOpenApi::getInstance()->request($url, $param, $isPOST, $applyToken)
yibanweb网站调用:
    $api =YBOpenApi::getInstance()->init('', '', '');
    $au  = $api->getAuthorize();

    //网站接入获取access_token,未授权则跳转至授权页面
    $info = $au->getToken();
    if(!$info['status']) {//授权失败
        session('token',$info['msg']);
        echo $info['msg'];
        die;
    }
yiban轻应用调用:
    $api =YBOpenApi::getInstance()->init('', '', '');
    $iapp  = $api->getIApp();
    try {
        //轻应用获取access_token,未授权则跳转至授权页面
        $info = $iapp->perform();
    } catch (YBException $ex) {
        echo $ex->getMessage();
    }   
    $token = $info['visit_oauth']['access_token'];//轻应用获取的token
    $api->bind($token);
    $yibanuser = $api->request('user/real_me');
    var_dump($yibanuser['info']);
来调用易班api参数说明:

$url String 具体调用的接口名称,例如user/me

$param Array 接口请求参数数组

$isPOST Boolean 是否使用POST方式请求,默认使用GET方式

$applyToken Boolean 请求参数中是否需要添加access_token,设置为true时自动添加之前绑定的token到参数数组中(如果为true请先通过bind()将token绑定至实例中)

以 获取当前用户信息 为例:(接口说明 https://o.yiban.cn/wiki/index.php?page=user/me

$url = 'user/me';

$param = array();

$isPOST = false;

$applyToken = true;

$result = YBOpenApi::getInstance()->request($url, $param, $isPOST, $applyToken);//获取接口返回信息

Comments ( 0 )

Sign in for post a comment

1
https://gitee.com/likecy/yiban.git
git@gitee.com:likecy/yiban.git
likecy
yiban
yiban
master

Search