【问题标题】:Bittrex API requestBittrex API 请求
【发布时间】:2017-08-18 09:06:54
【问题描述】:

我正在尝试使用 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,我不明白为什么。 感谢您的帮助!

【问题讨论】:

标签: php html json api web


【解决方案1】:

尝试添加进一步的错误处理, 像这样的东西

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);

}

【讨论】:

  • 我遇到了这个错误:致命错误:Curl failed with error #60:SSL 证书问题:无法获取本地颁发者证书
  • 在实时网站或 IP 上执行您的代码。正如我所经历的那样,这在您的本地系统中不起作用。
猜你喜欢
  • 2017-11-20
  • 1970-01-01
  • 2018-01-23
  • 2018-06-16
  • 2017-12-16
  • 2018-05-29
  • 1970-01-01
  • 2020-06-18
  • 1970-01-01
相关资源
最近更新 更多