uniondrug/service-sdk

ServiceSDK

3.501.006 2021-10-22 09:48 UTC

This package is auto-updated.

Last update: 2021-10-22 09:55:47 UTC


README

how to do

如何使用V3版本SDK

  1. 修改composer.json文件, 选择3.x版本
    {
        .
        .
        "require" : {
            .
            .
            "uniondrug/service-sdk" : "^3.0",
            .
            .
        },
        .
        .
        "scripts" : {
            "post-autoload-dump" : "Uniondrug\\ServiceSdk\\Bases\\Ide::builder"
        }
    }
    
  2. 执行composer update更新依赖版
  3. 修改config/app.php应用
       return [
           'default' => [
               .
               .
               .
               'providers' => [
                   .
                   .
                   .
                   \Uniondrug\ServiceSdk\Provider::class
               ]
           ]
       ];
    
  4. 设置config/sdk.php配置文件, 从vendor/uniondrug/service-sdk/docs/sdk.php中复制即可
  5. 去除ServiceTrait中对于$sdk@property定义(可选, 若有则去除).

how to run

  1. 标准调用
    $response = $this->serviceSdk->module->user->login(["mobile" => "13966013721"]);
    if ($response->hasError()){
       echo $response->getError();
    } else {
       echo $response->toJson();
    }
    
  2. 基础调用 - 常用的7种Restful方式
    $this->serviceSdk->delete("http://wxapi.uniondrug.cn/v/user");
    $this->serviceSdk->get("http://wxapi.uniondrug.cn/v/user");
    
  3. 兼容模式 - 待废弃
    $response = $this->serviceSdk->user->login(["mobile" => "13966013721"]);
    if ($response->hasError()){
       echo $response->getError();
    } else {
       echo $response->toJson();
    }