api - 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×tamp='.$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);
?>
解决方案
我确实解决了这个问题,如果您以毫秒而不是秒为单位编写 nonce 参数,那么它可以工作,如果您仍然遇到困难,请尝试更改 recwindow 值:
$nonce=round(microtime(true) * 1000); //时间();
推荐阅读
- javascript - How to get Flask app to refresh after updating JS code without having to clear browsing data
- java - Send a kafka consumer record as json response from a resource and build again from json response
- python - 正则表达式在 Python 中使用数字字符和后续值拆分字符串
- git - 无法在git中的分支之间切换
- snowflake-cloud-data-platform - 雪花外部表 DDL
- html - 无法让表格响应
- python - 在 python pdb 下,当在 __del__ 方法中到达断点时,如果 gc 是原因,堆栈会是什么样子?
- python-3.x - Keras ConvLSTM Regressor 在密集层抛出值错误
- python - 使用给定的一组特征在 python 中估算时间序列数据
- sql - SQL Server 查询 (MAX+COUNT)