"{"code":-1002,"msg":"You are not authorized to execute this request."}" - В чем может быть проблема API Biinance?
if ($stmt_check->num_rows > 0) {
echo "Transaction already deposited";
// signature
$api_key = 'x';
$secret_key = 'z';
$fromAsset = $send_currency;
$toAsset = $receive_currency;
$fromAmount = $send_value;
$toAmount = $receive_amount;
$timestamp = round(microtime(true) * 1000);
$params = [
'fromAsset' => $fromAsset,
'toAsset' => $toAsset,
'fromAmount' => $fromAmount,
'timestamp' => $timestamp,
];
$signature = hash_hmac('sha256', http_build_query($params), $secret_key);
$params['signature'] = $signature;
$url = 'https://api.binance.com/sapi/v1/convert/getQuote';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url . '?' . http_build_query($params) . '&signature=' . $signature);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, '');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/x-www-form-urlencoded',
'X-MBX-APIKEY: ' . $api_key,
]);
$response = curl_exec($ch);
var_dump($response);
if (curl_errno($ch)) {
echo "Error: " . curl_error($ch);
}
curl_close($ch);
if ($response !== false) {
$quote_response = json_decode($response, true);
if (isset($quote_response['quoteId'])) {
// Process the quote response as needed
} else {
echo "Error: Unable to get quote from Binance API";
}
} else {
echo "Error: Unable to connect to Binance API";
}
Есть фрагмент кода PHP который должен выполнять обмен крипто активов, но выдается ошибка которую я указал в названии вопроса. все нужные права у api есть.