我试图通过bittrex API来平衡我的钱包,我不明白为什么bittrex文档提供的代码不起作用:
$apikey = 'xxx';
$apisecret = 'xxx';
$nonce = time();
$uri = 'https://bittrex.com/api/v1.1/market/getopenorders?apikey=' .
$apikey . '&nonce=' . $nonce;
$sign = hash_hmac('sha512', $uri, $apisecret);
$ch = curl_init($uri);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('apisign:' . $sign));
$execResult = curl_exec($ch);
$obj = json_decode($execResult);
curl_exec
函数返回false,我不明白为什么。
谢谢你的帮助!
答案 0 :(得分:0)
尝试添加进一步的错误处理, 这样的事情
try {
$ch = curl_init();
if (FALSE === $ch)
throw new Exception('failed to initialize');
curl_setopt($ch, CURLOPT_URL, $uri);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$execResult = curl_exec($ch);
if (FALSE === $execResult)
throw new Exception(curl_error($ch), curl_errno($ch));
} catch(Exception $e) {
trigger_error(sprintf(
'Curl failed with error #%d: %s',
$e->getCode(), $e->getMessage()),
E_USER_ERROR);
}