我正在尝试使用需要使用私钥对进行身份验证的API。
以下是API文档:
这是我的代码。我没有收到任何错误,但没有交易。我的编码技巧不是最敏锐,没有错误,我被卡住了!
<?php
ini_set('display_errors', 'On');
error_reporting(E_ALL);
// Generate random amount between 28.00 and 30.00
$ran1 = mt_rand(2800, 3000);
$ran2 = $ran1/100;
// Config
$sAPIKey = "mykey"; // private key
$sAPISecret = "mysecret"; // api secret
$sPair = "GLD_BTC";
// $sAmount = "1.00";
$sRate = "0.0001";
$sNonce = time();
// Request
$sRequest = "https://tradesatoshi.com/api/private/submitorder?API_PUBLIC_KEY=" . $sAPIKey . "&Market=" . $sPair . "&Type=" . 'Buy' . "&Amount=" . $ran2 . "&Price=" . $sRate . "&nonce=" . $sNonce;
$sSign=hash_hmac('sha512', $sRequest, $sAPISecret);
$ch = curl_init($sRequest);
// disable cert validation
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); // shouldn't need this
// curl_setopt($ch, CURLOPT_HTTPHEADER, array('apisign:' . $sSign));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, array('apisign:' . $sSign));
$execResult = curl_exec($ch);
?>
任何指导都将得到衷心的感谢。