p2p link not working tried different ones none of them worked
Sample code below:
// Function to get data about P2P trades Binance
function get_p2p_data() {
// Binance API keys
$api_key = 'my api key';
$secret_key = 'my secret key';
// URL to access the Binance p2p API
$url = 'https://api.binance.com/api/v3/trades';
// Request parameters
$params = array(
'symbol' => 'BTCUSDT',
'limit' => 10
);
// Create a signature for the request
$query_string = http_build_query($params);
$signature = hash_hmac('sha256', $query_string, $secret_key);
// Adding a signature to the request parameters
$params['signature'] = $signature;
// Create a URL for the request
$url .= '?' . http_build_query($params);
// Sending a request to the Binance API
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
// Handling the response
$data = json_decode($response, true);
// Formation of an array with data on transactions P2P Binance
$p2p_data = array();
foreach ($data['asks'] as $ask) {
$p2p_data[] = array(
'pair' => 'BTC/USDT',
'price' => $ask[0],
'amount' => $ask[1]
);
}
foreach ($data['bids'] as $bid) {
$p2p_data[] = array(
'pair' => 'BTC/USDT',
'price' => $bid[0],
'amount' => $bid[1]
);
}
return $p2p_data;
}