Giter Site home page Giter Site logo

xiaoet's Introduction

小鹅通云服务PHPSDK

官方文档 https://api-doc.xiaoe-tech.com/index.php?s=/2&page_id=420

通过Composer安装

composer require easelify/xiaoet

国内用户建议使用阿里云的Composer镜像下载速度快,本项目默认也是使用该镜像!

使用范例

use xiaoet\Client;
use xiaoet\request\AccessTokenRequest;
use xiaoet\request\UserInfoGetRequest;

// 创建 Client 对象
$config = [
    'app_id' => 'your app id',
    'client_id' => 'your client id',
    'app_secret' => 'your app secret',
];
$client = new Client($config);

// 获取 access token
$req = new AccessTokenRequest();
$req->setAppId($config['app_id']);
$req->setClientId($config['client_id']);
$req->setSecretKey($config['app_secret']);
$rs = $client->execute($req);

$accessToken = '';
if ($rs['code'] == 0) {
    // 可储存$accessToken到数据库或文件备用
    // 根据 expires_in 字段做统一获取
    $accessToken = $rs['data']['access_token'];
} else {
    throw new \Exception('Access Token 获取失败: ' . $rs['msg']);
}

// 获取用户信息
$req = new UserInfoGetRequest();
$req->setUserId('u_5ec2a39b6857a_vG4siBRLLy');
$rs = $client->execute($req, $accessToken);
print_r($rs);

更多范例详见 ./tests 目录

交流

欢迎关注公众号:不用上班的程序员

qrcode

Licensing

Licensed under the 3-clause BSD license. See the LICENSE file for details.

xiaoet's People

Contributors

easelify avatar

Stargazers

 avatar  avatar  avatar  avatar

Forkers

xibusuper

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.