<?php
ob_start();
header('Content-Type: application/json');
if (isset($_GET['text']) && isset($_GET['from'])) {
$text = $_GET['text'];
$direction = $_GET['from'];
if ($direction == 'ru') {
$mod = 'lattocyr';
} elseif ($direction == 'uz') {
$mod = 'cyrtolat';
} else {
echo json_encode(['error' => 'Nimadir xato ketdi'], JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
exit;
}
function performPostRequest($url, $postData, $headers) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_ENCODING, '');
$response = curl_exec($ch);
if ($response === false) {
$error = curl_error($ch);
curl_close($ch);
return json_encode(['error' => 'cURL Error: ' . $error]);
}
curl_close($ch);
return $response;
}
$headers = [
'Accept: */*',
'Accept-Encoding: gzip, deflate, br, zstd',
'Accept-Language: ru-RU,ru;q=0.9,en-US;q=0.8,en;q=0.7',
'Content-Type: application/json',
'Cookie: _ym_uid=1708944258405837763; _ym_d=1708944258; _gid=GA1.2.357884963.1718511301; _gat_UA-151352532-1=1; _ym_isad=2; _ym_visorc=w; XSRF-TOKEN=eyJpdiI6ImdISmpLSkdWbmpaaWtxZjdrZ25QMEE9PSIsInZhbHVlIjoiVVkxQ0RwVnVkcElLSnZhR1JML3R5TFZNR1V1bW1rOUdSSmMrMmpHZzhpdW5xeDQra0hWV1NLbjh6Y2FDU2tnOG5TWmhSOEIwRjk4UXo4NG5hQzdaRnpnNEdaVkZac0sxSysvQjRKTkVkK1I2WVBzQ1pJeTRVNE5paXBEcm0xNTciLCJtYWMiOiJjMWU0ODU2NTMzNTBiOTRjY2U3MmE1YWM5MTY2Y2RlYjcwZDM2ZTQ4YTIzODhhOWJiZmE2ZmFkY2UxZWIwNzBiIiwidGFnIjoiIn0%3D; lotinuz_session=eyJpdiI6IllqYWpiMGJ4N3pPUXhuQ0pTMjJjemc9PSIsInZhbHVlIjoiSytSUnE4djRNYW5OTGRoYUpxWG0weklWNHQ1VXNIaUtaR0Z5R0JqbExyRktCeGNFeGx0bFBOUDRhVnBZZTNTTy9iQjVQd1gxQjgrSVhGOWlEYUpBWWVqL1dtOGxPWDdDd0lxMUg2SE9IQkYwRFVidTBDNXhRL1U4TnczcTMzVE0iLCJtYWMiOiI2ZGNlOWYwNTgxZDJkM2FlZjUxZGRhMTgyNGEzNTBlZmViZWUyMjBkMDM5NGY0NjEzZGUyOGI3YmMxZmM4ODU0IiwidGFnIjoiIn0%3D; _ga_ZPE569JKST=GS1.1.1718511300.8.1.1718511308.0.0.0; _ga=GA1.1.1856469339.1708944258',
'Origin: https://lotin.uz',
'Referer: https://lotin.uz/',
'Sec-Ch-Ua: "Google Chrome";v="125", "Chromium";v="125", "Not.A/Brand";v="24"',
'Sec-Ch-Ua-Mobile: ?0',
'Sec-Ch-Ua-Platform: "Windows"',
'Sec-Fetch-Dest: empty',
'Sec-Fetch-Mode: cors',
'Sec-Fetch-Site: same-origin',
'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36'
];
$postData = json_encode([
'text' => $text,
'from' => 'en',
'to' => 'ru',
'mod' => $mod
]);
$response = performPostRequest('https://lotin.uz/api/translate', $postData, $headers);
$data = json_decode($response, true);
if (json_last_error() !== JSON_ERROR_NONE) {
echo json_encode(['error' => 'JSON Decode Error: ' . json_last_error_msg()], JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
} else {
echo json_encode($data, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
}
} else {
echo json_encode(['error' => null], JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
}
?>
🌐 Ushbu API Lotin.uz sayitidan olindi✅🔸Manba: @Uzcoder_kanal
👩💻Dasturchi: @uzb_cristalPostni ko'rdingmi ? Reaksiya bosib ket o'lib qomisanku