Hi guys,
when i try to place a test order, i get the following error message:
400{"code":-1104,"msg":"Not all sent parameters were read; read '2' parameter(s) but was sent '5'."}
I only asked for mandatory values that are also mandatory according to Binance API Documentation, namely symbol, side, type and timestamp:
$TradesUrl='https://testnet.binance.vision/api/v3/order?symbol=LTCUSDT&side=BUY&type=MARKET&quantity=1×tamp=1659204341';
$TradesTicker = new APIREST($TradesUrl);
$CallTrades= $TradesTicker->call(array('X-MBX-APIKEY:'.$ApiKey));
Where could the problem be?
dino
2
You should send as “POST” method.
I feel like there is something missing in the code, right?
This is the code for my testorder.php, which works great for GET (balances):
<?php
include('API.php');
$ServerTimeUrl='https://testnet.binance.vision/api/v3/time';
$ClassServerTime = new APIREST($ServerTimeUrl);
$CallServerTime = $ClassServerTime->call(array());
$DecodeCallTime= json_decode($CallServerTime);
$Time = $DecodeCallTime->serverTime;
$ApiKey = $myapi; // the Api key provided by binance
$ApiSecret= $myapikey; // the Secret key provided by binance
$Timestamp = 'timestamp='.$Time; // build timestamp type url get
$Signature = hash_hmac('SHA256',$Timestamp ,$ApiSecret); // build firm with sha256
$Symbol = 'ETHUSDT';
$Side = 'BUY';
$Type = 'MARKET';
$TimeInForce = 'GTC';
$Quantity = '10';
$TradesUrl='https://testnet.binance.vision/api/v3/order?symbol=LTCBTC×tamp='.$Time.'&signature='.$Signature;
$TradesResponse = new APIREST($TradesUrl);
$CallTrades= $TradesResponse->call(array('X-MBX-APIKEY:'.$ApiKey));
$array = json_decode($CallTrades, true);
?>
And this is the api.php:
<?php
$myapi = 'J4BhGpAmTyU5FQJxUEM905aKQqWoxo2uMfTgORiy9x49eqQ0P1Kdp9wX765VMkbg'; //test vision
$myapikey = 'tsXRslYK3zV47XOvqqrBlrBSkHYvIMxuUETT5Re3ak5lgsSvnJ2GwGydnwItc3LQ'; //test vision
class APIREST
{
private $url;
/**
* Constructor for the class,
* you must send the url to initialize the class
*
* @return $url
*/
public function __construct($url)
{
$this->url = $url;
}
/**
* @param $httpheader array of headers
* @return response
*/
public function call($httpheader)
{
try
{
$curl = curl_init();
if (FALSE === $curl)
throw new Exception('Failed to initialize');
curl_setopt_array($curl, array(
CURLOPT_URL => $this->url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 60,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => $httpheader,
));
$response = curl_exec($curl);
if (FALSE === $response)
throw new Exception(curl_error($curl), curl_errno($curl));
$http_status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
if (200 != $http_status)
throw new Exception($response, $http_status);
curl_close($curl);
}
catch(Exception $e)
{
$response= $e->getCode() . $e->getMessage();
echo $response;
}
return $response;
}
}
?>
Could someone please help me?
Thanks