POST order error: "code":-1022,"msg":"Signature for this request is not valid."

Why isn’t the script running? With the GET requests (balances, account, klines) the signature works, only with the POST requests do I get this error message.
According to the documentation, the signature is also correct and the ORDER is also executed in Postman. Just not on my web server.
Please help.

Here’s my code, exactly the same as in Postman:

<?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 = $myapikey; // the Api key provided by binance
$ApiSecret = $myapisecret; // the Secret key provided by binance
$Timestamp = 'timestamp='.$Time; // build timestamp type url get
$Signature = hash_hmac('SHA256',$Timestamp ,$ApiSecret); // build firm with sha256

$curl = curl_init();
$Symbol = 'BNBUSDT';
$Side = 'BUY';
$Type = 'MARKET';
$Quantity = '10';

curl_setopt_array($curl, array(
    CURLOPT_URL => 'https://testnet.binance.vision/api/v3/order?symbol='.$Symbol.'&side='.$Side.'&type='.$Type.'&quantity='.$Quantity.'&timestamp='.$Time.'&signature='.$Signature,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => '',
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 0,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_HTTPHEADER => array(
      'Content-Type: application/json',
      'X-MBX-APIKEY: J4BhGpAmTyU5FQJxUEM905aKQqWoxo2uMfTgORiy9x49eqQ0P1Kdp9wX765VMkbg'
    ),
  ));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

?>

Check the response received to better diagnose the issue.

Sorry, but this is the response: [“code”:-1022,”msg”:”Signature for this request is not valid.”]

Are you using the API Key and Secret Key generated from https://testnet.binancefuture.com/ ?

Are you sure it is working on Postman? Signature needs to generated from all query params combined, not just timestamp. Also, api/secret key isn’t the same on both testnet and mainnet.

As you can see, it’s exactly the same code as in Postman.

And as already said, the GET queries work on my web server, but not the POST queries because it doesn’t accept the signature here.

Unfortunately we cannot help debug custom code as there are too many factors and causes of errors. I suggest having a look at the official Binance PHP connector on Github.

This code snippet generated from postman is NOT the SAME code that runs the post request.
Since you can make the request in postman, it’s easy to print out the raw HTTP request sent to server, then compare it with your code.

And here you go: