This is my working code:
- for get balances:
$timestamp = time()*1000;
$url = "https://api.bittrex.com/v3/balances";
$method = "GET";
$content = "";
$subaccountId = "";
$contentHash = hash('sha512', $content);
$preSign = $timestamp . $url . $method . $contentHash . $subaccountId;
$signature = hash_hmac('sha512', $preSign, $apisecret);
$headers = array(
"Accept: application/json",
"Content-Type: application/json",
"Api-Key: ".$apikey."",
"Api-Signature: ".$signature."",
"Api-Timestamp: ".$timestamp."",
"Api-Content-Hash: ".$contentHash.""
);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
$execResult = curl_exec($ch);
curl_close($ch);
echo $execResult;
- for create a new order:
$timestamp = time()*1000;
$url = "https://api.bittrex.com/v3/orders";
$method = "POST";
$content = '{
"marketSymbol": "BTC-USDT",
"direction": "BUY",
"type": "LIMIT",
"quantity": "0.00276225",
"limit": "7226.00306482",
"timeInForce": "GOOD_TIL_CANCELLED"
}';
$subaccountId = "";
$contentHash = hash('sha512', $content);
$preSign = $timestamp . $url . $method . $contentHash . $subaccountId;
$signature = hash_hmac('sha512', $preSign, $apisecret);
$headers = array(
"Accept: application/json",
"Content-Type: application/json",
"Api-Key: ".$apikey."",
"Api-Signature: ".$signature."",
"Api-Timestamp: ".$timestamp."",
"Api-Content-Hash: ".$contentHash.""
);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, $content);
$execResult = curl_exec($ch);
curl_close($ch);
echo $execResult;