作者 karlet

feat:listenkey

... ... @@ -33,7 +33,7 @@ class BinanceSpot
{
$len = count($param);
if ($len == 0) {
output('param 为空,签名失败');
// output('param 为空,签名失败');
return $param;
}
$paramStr = http_build_query($param);
... ... @@ -62,6 +62,28 @@ class BinanceSpot
}
return json_decode($data, true);
}
private function requestListenKey($method, $path, $param)
{
$url = $this->createUrl($path);
// $param['timestamp'] = getMicrotime();
$param['signature'] = $this->createSign($this->secret, $param);
$header = $this->createHeader($this->apikey);
if (!in_array(strtoupper($method), ['GET', 'POST', 'DELETE'])) {
output('请求方法错误', $method, $path, $param);
return 0;
}
$data = json_encode([]);
if (strtoupper($method) == 'POST') {
$data = Curl::httpPost($url, $param, $header);
}
if (strtoupper($method) == 'GET') {
$data = Curl::httpGet($url, $param, $header);
}
if (strtoupper($method) == 'DELETE') {
$data = Curl::httpDelete($url, $param, $header);
}
return json_decode($data, true);
}
static private function requestMarket($method, $path, $param)
{
... ... @@ -151,14 +173,14 @@ class BinanceSpot
{
$path = '/api/v3/userDataStream';
$method = 'POST';
return $this->requestMarket($method, $path, $param);
return $this->requestListenKey($method, $path, $param);
}
//延长 Listen Key 有效期 (USER_STREAM)
public function listenKeyDelay($param)
{
$path = '/api/v3/userDataStream';
$method = 'PUT';
return $this->requestMarket($method, $path, $param);
return $this->requestListenKey($method, $path, $param);
}
/*
... ...