【问题标题】:error string(161) " Cannot POST /api/2/trading/balance " HitBTC Api PHP错误字符串(161)“无法发布 /api/2/trading/balance”HitBTC Api PHP
【发布时间】:2019-11-17 14:28:01
【问题描述】:

我下面的代码不起作用,我主要是想显示账户余额,我使用var_dum($curl_response) 来实际查看代码停止的位置,因为如果我转储最终结果,我会得到空值。

<?php
 $headers = array ( "Content-Type: application/json" );
 $service_url = 'https://api.hitbtc.com/api/2/trading/balance';
$curl = curl_init($service_url);
curl_setopt ($curl, CURLOPT_HTTPHEADER, $headers );
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($curl, CURLOPT_USERPWD, "xxxx:xxx"); //Your credentials goes here
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $curl_post_data);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); //IMP if the url has https and you don't want to verify source certificate

$curl_response = curl_exec($curl);
$response = json_decode($curl_response);
curl_close($curl);

var_dump($curl_response);

?>

【问题讨论】:

    标签: php json api


    【解决方案1】:

    只是为了那些来这里寻找答案的人,我自己修复了它,这是为了帮助你,这是真正适用于 HitBTC 而无需他们的 SDK。

    <?php
        $ch = curl_init('https://api.hitbtc.com/api/2/trading/balance'); curl_setopt($ch, CURLOPT_USERPWD, 'xxxx:xxxxx'); // API AND KEY
    $return = curl_exec($ch); curl_close($ch); print_r($return); ?>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-11-01
      • 2018-08-15
      • 1970-01-01
      • 2022-11-22
      • 1970-01-01
      • 2020-04-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多