Jane Jane - 1 month ago 19
JSON Question

Invalid API prameters

I created object call API when I set only

"info"
as parameter of method program run without any errors . When I'd set parameter like that ("swapList",$t) I get
{"error":407,"errorMsg":"Invalid value: currency","time":1476023664,"limit":{"used":5,"allowed":600,"expires":1476024000}}
.I tried alot of arrays set there but results was the same. Here is API documentation https://github.com/bitmarket-net/api

Here is my code

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

Answer

You pass the parameters array without key name.

Try with:

$t['currency'] = 'BTC';