PHP GDAX-API删除请求返回错误400“BadRequest”

时间:2018-01-03 14:22:47

标签: php curl http-delete gdax-api

我正在尝试取消限价订单,但继续使用唯一描述“BadRequest”获取状态400代码。我可以下订单并获得状态,余额等,但DELETE不起作用。以下是我的代码示例:

    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
  $url = $this->api_url . '/' . TRIM($path, "/"); $tm0 = microtime(true);

  $ch = curl_init(); $this->curl_setopt($ch);

  curl_setopt($ch, CURLOPT_URL, $url);  $timestamp = time(); $signature = $this->signature($path, $data, $timestamp, strtoupper($method));
     curl_setopt($ch, CURLOPT_HTTPHEADER, 
       [
        "CB-ACCESS-SIGN:"      . $signature,
        "CB-ACCESS-TIMESTAMP:"  . $timestamp,
        "CB-ACCESS-KEY:"      . $this->key,
        "CB-ACCESS-PASSPHRASE:" . $this->passphrase,
        "Content-Type:"   . 'application/json',
       ]
        );

     switch(strtoupper($method))
     {
         case "POST":
             curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));

             break;
         case "PUT":
             curl_setopt($ch, CURLOPT_PUT, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));

             break;
         case "DELETE":
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");

             break;
     }

  $res = curl_exec($ch); curl_close($ch); $ch = null; $this->doQuery($url, microtime(true) - $tm0, $data, $res); //echo "$res\n";

  if ($res)
  {
   return json_decode($res, true);
  }

  return $res;
 public function cancelOrder($order_id)
 {
  return $this->query('DELETE', "/orders/" . TRIM($order_id));
 }

请帮忙!

0 个答案:

没有答案