首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Bittrex API请求

Bittrex API请求
EN

Stack Overflow用户
提问于 2017-08-18 17:06:54
回答 1查看 1.1K关注 0票数 1

我试图用bittrex API来平衡我的钱包,我不明白bittrex文档提供的代码为什么不能工作:

代码语言:javascript
运行
复制
$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,我不明白为什么。感谢您的帮助!

EN

回答 1

Stack Overflow用户

发布于 2017-08-18 17:17:43

尝试添加更多的错误处理,如下所示

代码语言:javascript
运行
复制
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);

}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/45752776

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档