当我只设置"info"
作为方法程序运行参数而没有任何错误时,我创建了对象调用API。当我设置这样的参数(“swapList”,$ t)时,我得到{"error":407,"errorMsg":"Invalid value: currency","time":1476023664,"limit":{"used":5,"allowed":600,"expires":1476024000}}
。我尝试了很多数组,但结果是一样的。这是API文档https://github.com/bitmarket-net/api
这是我的代码
<html>
<body>
<?php
class API
{
public function bitmarket_api($method, $params = array())
{
$key = "XXXXXXXXXXXXXXXXXXXXX";
$secret = "XXXXXXXXXXXXXXXXXXXX";
$params["method"] = $method;
$params["tonce"] = time();
$post = http_build_query($params, "", "&");
$sign = hash_hmac("sha512", $post, $secret);
$headers = array(
"API-Key: " . $key,
"API-Hash: ". $sign,
);
$curl = curl_init();
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_URL, "https://www.bitmarket.pl/api2/");
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $post);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
$ret = curl_exec($curl);
if ($ret === false)
{
die(curl_error($curl));
}
echo $ret;
}
}
$t[]='BTC';
$z =new API;
$z->bitmarket_api('swapList',$t);
?>
</body>
</html>
答案 0 :(得分:0)
您传递的参数数组没有键名。
尝试:
$t['currency'] = 'BTC';