vtoday/shucang

v1.0.1 2022-09-07 03:50 UTC

This package is not auto-updated.

Last update: 2024-05-15 11:35:13 UTC


README

安装

composer require vtoday/shucang

客户端初始化

include "./vendor/autoload.php";

$appId = "1002";
$privateKey = "MIIEvAIBADANBgkq......jkl9aD/5k8I/Hag==";
$publicKey = "MIIBIjANBgkq......IDAQAB";


try {
    $client = new \Vtoday\Shucang\Client($appId, $privateKey, $publicKey, false);

} catch (\Vtoday\Shucang\Exceptions\ConfigurationException $e) {
    //do something ...

}

调用同步藏品信息接口

try {
    $client->doRequest("collection.info.sync", [
        "product_id"   => "123",
        "product_name" => "cccccccccccc",
        //other fields......
        //注意字段值类型,需要严格匹配类型值
    ]);
} catch (\Vtoday\Shucang\Exceptions\InvalidParamException $e) {
    // do something ...

}

提供查询用户信息接口

try {
    $method = "";
    [$method, $data] = $client->parseRequestData();

    $bizData = [];

    if ($method == "user.info") {
        $bizData = [
            "user_id" => "123", // 字符串类型
            "wallet_address" => "xxxxxx",
            "verify_sign" => "eeeeee",
        ];
    }
    // do something ......

    $response = $client->genSignResponse(\Vtoday\Shucang\Client::SUCCESS_CODE, "成功", $method, $bizData);
    
} catch (\Vtoday\Shucang\Exceptions\ApiException $exception) {
    $response = $client->genSignResponse($exception->getErrCode(), $exception->getErrMessage(), $method);
    // do something ......
}catch(\Exception $exception){
    $response = $client->genSignResponse("5500", $exception->getMessage(), $method);
    // do something ......
}

//return $response