Skip to content

vtoday/shucang-php

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

今日数字藏品交易服务平台--PHP版SDK

安装

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

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages