Hi! Could we please enable some services and cookies to improve your experience and our website?
Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code
<?php
// 1. تنظیمات cURL
$url = "https://api.coinex.com/v2/spot/ticker?market=BTCUSDT";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// 2. اجرای درخواست
$response = curl_exec($ch);
// 3. بررسی خطا
if ($response === false) {
echo "خطای cURL: " . curl_error($ch);
} else {
$data = json_decode($response, true);
if (isset($data['data'][0]['last'])) {
echo "قیمت بیتکوین: " . $data['data'][0]['last'] . " USDT";
}
}
// 4. بستن هندل
curl_close($ch);
?>