Criar uma ordem de compra usando a API da PIONEX e php
€10-15 EUR
Sürüyor
İlan edilme: 6 gün önce
€10-15 EUR
Teslimde ödenir
Olá,
Gostaria de obter assistência para executar uma ordem de compra na PIONEX através da sua API, utilizando php.
Neste momento tenho um código, mas que vai dando alguns erros, e até ao momento ainda não consegui que a compra de crypto fosse bem sucedida. No fundo, preciso de um técnico que retifique o meu código, e o trabalho fica finalizado quando eu executar a primeira compra com sucesso.
Eis o código:
===============================================================
<?php
$apiKey = "xxxxxxxxxxxxxxxx"; // Substitui pela tua chave API
$apiSecret = "xxxxxxxxxxxxxxxx"; // Substitui pelo teu segredo API
$baseUrl = "[login to view URL]";
// 1) Endpoint + timestamp na query
$endpoint = "/api/v1/trade/order";
$timestamp = (int)(microtime(true) * 1000);
$queryString = "timestamp=" . $timestamp; // só o timestamp na query
$pathUrl = $endpoint . "?" . $queryString; // /api/v1/trade/order?timestamp=...
// 2) Corpo da requisição (JSON) - parâmetros da ordem
// Pionex (similar à Binance) exige "quoteOrderQty" para Market BUY
$bodyArray = [
"symbol" => "ETH_USDT",
"side" => "BUY",
"type" => "MARKET",
"quoteOrderQty" => "10" // gasta 10 USDT
];
// Transforma em JSON sem caracteres escapados
$bodyString = json_encode($bodyArray, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
// 3) Montar a string que será assinada:
// = "POST" + (endpoint + "?timestamp=...") + "&" + (JSON do body)
$signaturePayload = "POST" . $pathUrl . "&" . $bodyString;
// 4) Calcular a assinatura HMAC-SHA256
$signature = hash_hmac("sha256", $signaturePayload, $apiSecret);
// 5) Montar a URL completa
$url = $baseUrl . $pathUrl;
// 6) Preparar os headers (igual ao seu GET de saldo)
$headers = [
"PIONEX-KEY: $apiKey",
"PIONEX-SIGNATURE: $signature",
"Content-Type: application/json"
];
// 7) Executar a requisição POST
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $bodyString); // corpo em JSON
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
echo "HTTP Code: $httpCode\n";
echo "Response: $response\n";
?>
=======================================================
O output:
HTTP Code: 200 Response: {"result":false,"timestamp":1737581289440,"code":"INVALID_SIGNATURE","message":"invalid signature"}
Obrigado
I understand the frustration you're experiencing with getting your code to execute successful cryptocurrency purchases on PIONEX using their API. My name is Haziq, a highly skilled PHP developer, and I believe I'm the perfect fit for this project. I have an extensive background in working with APIs and solving complex coding problems. Over the years, I've developed a deep understanding of PIONEX's system, similar to Binance, which will help me instantly identify and rectify any errors in your code.
Drawing from my full-stack development experience, I'm adept at creating clean and efficient code that seamlessly integrates with different platforms. I'll review the entire script you've provided and address every error with utmost precision. Trust me; the day you successfully execute your first cryptocurrency purchase on PIONEX will be the same day we consider our work complete.
To further streamline the process, I'll provide detailed documentation along with practical explanations covering every step from authorization to sending each request using PIONEX's API. This way, not only will you have a fully functional solution but also a clear understanding of how each part of your project works together. Let's overcome this hurdle together; I'm eager and ready to help you succeed!
€13 EUR 2 gün içinde
0,0
(0 değerlendirme)
0,0
0,0
2 freelancer bu proje için ortalama €32 EUR teklif veriyor