PHP读取API - 未发送强制参数

时间:2018-01-03 23:07:57

标签: php api parameters

我熟悉使用API​​。我有以下问题:

错误是:

Fatal error: Uncaught Larislackers\BinanceApi\Exception\BinanceApiException: [-1102]: Mandatory parameter 'timestamp' was not sent, was empty/null, or malformed. thrown in C:\Users\Francisco\vendor\larislackers\php-binance\src\BinanceApiContainer.php on line 568

编辑:这是班级:https://larislackers.github.io/php-binance/source-class-Larislackers.BinanceApi.BinanceApiContainer.html#276-291

我注意到这是因为TIMESTAMP是强制性的: https://www.binance.com/restapipub.html#current-open-orders-signed

有人能为我提供一个如何填写时间戳的示例吗? 到目前为止,这是我的代码:

$orders = $bac->getOpenOrders(['symbol' => 'XVGETH']);
var_dump($orders->getBody()->getContents());

1 个答案:

答案 0 :(得分:0)

timestamp密钥添加到$params阵列。

$orders = $bac->getOpenOrders(['symbol' => 'XVGETH', 'timestamp' => time()]);

time()返回当前时间。如果您想要其他时间,可以使用许多日期时间功能。它也只是一个代表以秒为单位的时间的数字,你可以执行像time() - 86400这样的普通算术来获取昨天的当前时间。

有关Binance API如何使用timestamp选项,请参阅https://www.binance.com/restapipub.html