llomgui / wootrade
Wootrade API 的 PHP SDK
v1.0.0
2022-03-23 13:03 UTC
Requires
- php: >=8.0.0
- ext-json: *
- guzzlehttp/guzzle: ^6.0|^7.0
- monolog/monolog: ~1.0|~2.0
- ratchet/pawl: ^0.4.1
README
要求
安装
通过 Composer 安装包。
composer require "llomgui/wootrade"
调试模式 & 日志记录
use llomgui\Wootrade\WootradeApi; // Debug mode will record the logs of API to files in the directory "WootradeApi::getLogPath()" according to the minimum log level "WootradeApi::getLogLevel()". WootradeApi::setDebugMode(true); // Logging in your code // WootradeApi::setLogPath('/tmp'); // WootradeApi::setLogLevel(Monolog\Logger::DEBUG); WootradeApi::getLogger()->debug("I'm a debug message");
示例
public 端点的 API 示例
use llomgui\Wootrade\PublicApi\Exchange; $exchange = new Exchange(); $result = $exchange->get('SPOT_BTC_USDT'); var_dump($result);
private 端点的 API 示例
use llomgui\Wootrade\Auth; use llomgui\Wootrade\PrivateApi\Account; use llomgui\Wootrade\Exceptions\HttpException; use llomgui\Wootrade\Exceptions\BusinessException; $auth = new Auth('API_KEY', 'API_SECRET'); $account = new Account($auth); try { $result = $account->getInformation(); var_dump($result); } catch (HttpException $e) { var_dump($e->getMessage()); } catch (BusinessException $e) { var_dump($e->getMessage()); }