-9000 Illegal Parameter Issue (PHP Wrapper)

Hi,

I’m trying to use this method :
POST /wapi/v3/withdraw.html (HMAC SHA256)

Issue :
-9000=illegal parameter

I use PHP wrapper, and I have succeed to use Balance, Order, Price method for exemple. So I assume that every parameters are built, and send correctly, to the right endpoint.


The adress is valid, founds are available.

// POST array()
Array ( [asset] => ETH [adress] => 0x6d16Dc64a9885b45Bad7c2046e88Ad********** [amount] => 0.03 [recvWindow] => 50000 [timestamp] => 1611408782989 [signature] => 19d7669948082a4cf6df508a596bce4d3d2322d5852c5c56b8a1c74b24ce855a )

// curl_getinfo() (what I send)
Array ( [url] => https://api.binance.com/wapi/v3/withdraw.html?asset=ETH&adress=0x6d16Dc64a9885b45Bad7c2046e88Ad**********&amount=0.03&recvWindow=50000×tamp=1611408782989&signature=19d7669948082a4cf6df508a596bce4d3d2322d5852c5c56b8a1c74b24ce855a [content_type] => application/json;charset=UTF-8 [http_code] => 200 [header_size] => 858 [request_size] => 452 [filetime] => -1 [ssl_verify_result] => 0 [redirect_count] => 0 [total_time] => 0.597427 [namelookup_time] => 0.065727 [connect_time] => 0.10975 [pretransfer_time] => 0.261898 [size_upload] => 0 [size_download] => 49 [speed_download] => 82 [speed_upload] => 0 [download_content_length] => 49 [upload_content_length] => -1 [starttransfer_time] => 0.597321 [redirect_time] => 0 [redirect_url] => [primary_ip] => 52.84.150.39 [certinfo] => Array ( ) [primary_port] => 443 [local_ip] => 192.168.1.3 [local_port] => 53972 )

// Response
Array ( [msg] => -9000=illegal parameter [success] => )


Does anyone have a clue on what’s going on ?

If you need further informations, I’ll give you everything needed.

Thank’s for your advice,

Array ( [url] => https://api.binance.com/wapi/v3/withdraw.html?asset=ETH&adress=0x6d16Dc64a9885b45Bad7c2046e88Ad**********&amount=0.03&recvWindow=50000

Is this a typo or you really pass this way?
Paste all your php code here to see what went wrong

Is just HTML doing this, when it’s rendering. (&times = x)

Main Function :

public function withdraw($asset, $adress, $amount) {
    $url = '/wapi/v3/withdraw.html';

    $request = [
        'asset'     => $asset,
        'adress'     => $adress,
        'amount'     => $amount,
    ];

    return $this->queryPrivate('POST', $url, $request);
}

Query Private adding recvWindow (set by default at 5000) :

public function queryPrivate($method, $url, array $request = array()) {
    try {
        if(!isset($request['recvWindow'])) {
            $request['recvWindow'] = $this->recvWindow;
        }

        return $this->request2(
            $method,
            $url,
            $request,
            true
        );
    } catch (BinanceApiException $e) {
        return $this->processException($e, $method, $url, $request);
    }
}

Then, Query Constructor :

Constructor : (Init CURL and some params)

public function __construct($key, $secret, $url = ‘https://api.binance.com’, $sslverify = true) {
$this->key = $key;
$this->secret = $secret;
$this->url = $url;

$this->curl = curl_init();

curl_setopt_array($this->curl, array(
    CURLOPT_SSL_VERIFYPEER => $sslverify,
    CURLOPT_SSL_VERIFYHOST => 2,
    CURLOPT_USERAGENT      => 'Binance PHP API wrapper',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_TIMEOUT        => 20
));

}

Then main function, building final query :

private function request2($method, $url, array $request = array(), $signed = false) {
$query = http_build_query($request, ‘’, ‘&’);

//add endpoint to the base url
$path = $this->url . $url;

// if signed, adding timestamp and build signature.
// building query for the url
// building request array for POST method
if ($signed) {
    $timestamp = microtime(true) * 1000;
    $query .= '&timestamp=' . number_format($timestamp, 0, '.', '');
    $request['timestamp'] = number_format($timestamp, 0, '.', '');

    $signature = hash_hmac('sha256', $query, $this->secret);

    if($method === "POST"){
        $request['signature'] = $signature;
    }

    $query .= '&signature=' . $signature;

    curl_setopt($this->curl, CURLOPT_HTTPHEADER, array(
        'X-MBX-APIKEY: ' . $this->key,
    ));
}

if ($query) {
    $path .= '?' . $query;
}

curl_setopt($this->curl, CURLOPT_URL, $path);

print_r($request); //debug array send

//set method and build CURL OPT
switch ($method) {
    case 'POST':
        curl_setopt($this->curl, CURLOPT_POSTFIELDS, $request);
        curl_setopt($this->curl, CURLOPT_POST, true);
        break;
    case 'GET':
        break;
    default:
        throw new BinanceApiException('Unsupported method');
}

//execute request
$result = curl_exec($this->curl);

//debug headers
//$httpcode = curl_getinfo($this->curl);
//print_r($httpcode);

return json_decode($result, true);

}


Hope everything is clear enough,

  1. adress => address …
  2. Use query string instead of $request when setting up CURLOPT_POSTFIELDS

Hi,

  1. What should I do with this first line ? There is a lack of information…

  2. I tried :
    $query (string : param=value&param=value[…]) form.
    $request form (array()).

$request send me -9000, when $query return that nothing was sent. (expecting parameters)

It meas:
curl_setopt($this->curl, CURLOPT_POSTFIELDS, $request); => curl_setopt($this->curl, CURLOPT_POSTFIELDS, $query);

Yes, I already try that way,

It didn’t work, $query return that nothing was sent. (Mandatory parameter ‘amount’ was not sent)

but my $query looks :

asset=ETH&adress=0x0*****&amount=0.012&recvWindow=50000&timestamp=1611676387070&signature=734237688ef027967c8d8822bfd4689953895f48e69378198f2227b7e23e441a

You’re still using the wrong word - adress…
Read my suggestions again

Hi,

I want to apologize, from the start you gave me the right answer but I was so conviced that address had only one “d”.

Excuse me for loosing your time on a such stupid error.