首页 > 解决方案 > Binance Crypto Exchange API 错误 -1131 recvWindow 必须小于 60000

问题描述

我的 PHP 脚本有问题,该脚本以前可以正常工作。我不知道它为什么停止工作,因为我没有任何改变。

我收到错误消息:

array(2) { ["code"]=> int(-1131) ["msg"]=> string(37) "'recvWindow' 必须小于 60000。" }

所以我确实认为很容易,我只会将设置“recvWindow”设置为小于“60000”,但是接下来的错误消息也会出现在“recvWindow”中

array(2) { ["code"]=> int(-1021) ["msg"]=> string(56) "此请求的时间戳在 recvWindow 之外。" }

那么我必须做些什么才能让它再次工作有什么问题呢?这是我拥有的完整脚本:

        <?php
        //--API Call
        $nonce=time();
        //--
        $url='recvWindow=10000000000000000&timestamp='.$nonce;
        //--
        $sign=hash_hmac('SHA256',$url,$apisecret);
        $url=$url.'&signature='.$sign;
        $ch = curl_init($url);
        curl_setopt($ch, CURLOPT_HTTPHEADER, array('X-MBX-APIKEY:'.$apikey));
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
        curl_setopt($ch, CURLOPT_URL, "https://api.binance.com/api/v3/account?".$url);
        $execResult = curl_exec($ch);
        $Balances = json_decode($execResult, true);
        var_dump($Balances);
        ?>

标签: apibinance

解决方案


我确实解决了这个问题,如果您以毫秒而不是秒为单位编写 nonce 参数,那么它可以工作,如果您仍然遇到困难,请尝试更改 recwindow 值:

$nonce=round(microtime(true) * 1000); //时间();


推荐阅读