我正在用PHP创建一个bitmex
bot。
我成功取得了钱包余额。
但是无法发布新订单,它显示签名无效错误。
bitmex
网站上没有可用的PHP文档。
感谢任何帮助。
这是我正在使用的代码
$apiKey = "L5kwGvrsX-3FFsPtpO4jhXu9";
$apiSecret = "OCFCnv6M2jbz-S9vioj5Ytoyjyk5dPyrkY87ecmUDh74F_6V";
$expires = strtotime("+1 minutes");
$verb = "POST";
$path ="/api/v1/order";
$data = array('symbol' => 'XBTUSD','side'=>'Buy','orderQty'=>'100','ordType'=>'Market','timeInForce'=>'GoodTillCancel');
$data_json = json_encode($data);
$string = $verb.$path.(string)$expires.$data_json;
$sign = bin2hex(hash_hmac('sha256', $string, $apiSecret));
$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPHEADER,array(
"Content-Type : application/x-www-form-urlencoded",
"Accept : application/json",
"X-Requested-With: XMLHttpRequest",
"api-expires:".$expires,
"api-key: ".$apiKey,
"api-signature:".$sign
));
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_URL,"https://testnet.bitmex.com/api/v1/order");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,
$data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$server_output = curl_exec ($ch);
$information = curl_getinfo($ch, CURLINFO_HTTP_CODE);
print_r($information);
print_r($server_output);
curl_close ($ch);