Yangi formatda davom etish uchun: https://uzfor.net/view.php?act=post&id=91673
Postga havola
Tayota [667] [off]
Sorovda qandaydur xatolik bolsa uni ekran yoki faylga yozishni iloji bormi?
1 daqiqa 56 soniyadan keyin yozdi:
<?php
date_default_timezone_set('Asia/Tashkent');
//bot malumotlari
define('API_KEY', '1999018049:AAGxOv5S6On1qrsJvrCFteG1rhuBfiNCasA');
echo 'SetWebHook: <a href="https://api.telegram.org/bot'.API_KEY.'/setwebhook?url='.$_SERVER["SERVER_NAME"].''.$_SERVER["SCRIPT_NAME"].'"> https://api.telegram.org/bot'.API_KEY.'/setwebhook?url='.$_SERVER["SERVER_NAME"].''.$_SERVER["SCRIPT_NAME"].' </a> <hr/>';
//sorov yuborish
function tayota($uslub, $sorov = []) {
$manzil = 'https://api.telegram.org/bot'.API_KEY.'/'.$uslub;
$req = curl_init();
curl_setopt($req, CURLOPT_URL, $manzil);
curl_setopt($req, CURLOPT_RETURNTRANSFER, true);
curl_setopt($req, CURLOPT_POST, true);
curl_setopt($req, CURLOPT_POSTFIELDS, $sorov);
$res = curl_exec($req);
//curl_close($req);
if (curl_error($req)) {
var_dump(curl_error($req));
} else {
return json_decode($res);
}
}
//bot yozmoqda
function yozmoqda($chat_id, $turi = 'typing') {
tayota('sendChatAction', [
'chat_id' => ''.$chat_id.'',
'action' => ''.$turi.''
]);
}
//malumotlarni faylga saqlab qoyamiz
file_put_contents('sorov.txt', file_get_contents('php://input'));
//malumotlarni ózgaruvchiga saqlab olamiz
$tg = json_decode(file_get_contents('php://input'));
$xabar = $tg->message;
$xabar_matni = $xabar->text;
$chat_id = $xabar->chat->id;
$kimdan_id = $xabar->from->id;
$xabar_id = $xabar->message_id;
$ismi = $xabar->from->first_name;
$familyasi = $xabar->from->last_name;
$username = $xabar->from->username;
$toliq_ism = $ismi.' '.$familyasi;
if ($xabar_matni == "/start") {
file_put_contents('go.txt', file_get_contents('php://input'));
yozmoqda($chat_id, 'typing');
$matn = 'Salom botga xush kelibsiz';
tayota('sendMessage', [
'chat_id' => ''.$chat_id.'',
'parse_mode' => 'html',
'text' => 'salom'
]);
file_put_contents('ok.txt', file_get_contents('php://input'));
} else {
file_put_contents('log.txt', file_get_contents('php://input'));
}
3 daqiqa 10 soniyadan keyin yozdi:
Manashu ishlamayapti bironta xatolik ham kelmabdi logOut da
Oxiri negadur tg meni blokladi
{"ok":false,"error_code":401,"description":"Unauthorized"}
1 daqiqa 56 soniyadan keyin yozdi:
<?php
date_default_timezone_set('Asia/Tashkent');
//bot malumotlari
define('API_KEY', '1999018049:AAGxOv5S6On1qrsJvrCFteG1rhuBfiNCasA');
echo 'SetWebHook: <a href="https://api.telegram.org/bot'.API_KEY.'/setwebhook?url='.$_SERVER["SERVER_NAME"].''.$_SERVER["SCRIPT_NAME"].'"> https://api.telegram.org/bot'.API_KEY.'/setwebhook?url='.$_SERVER["SERVER_NAME"].''.$_SERVER["SCRIPT_NAME"].' </a> <hr/>';
//sorov yuborish
function tayota($uslub, $sorov = []) {
$manzil = 'https://api.telegram.org/bot'.API_KEY.'/'.$uslub;
$req = curl_init();
curl_setopt($req, CURLOPT_URL, $manzil);
curl_setopt($req, CURLOPT_RETURNTRANSFER, true);
curl_setopt($req, CURLOPT_POST, true);
curl_setopt($req, CURLOPT_POSTFIELDS, $sorov);
$res = curl_exec($req);
//curl_close($req);
if (curl_error($req)) {
var_dump(curl_error($req));
} else {
return json_decode($res);
}
}
//bot yozmoqda
function yozmoqda($chat_id, $turi = 'typing') {
tayota('sendChatAction', [
'chat_id' => ''.$chat_id.'',
'action' => ''.$turi.''
]);
}
//malumotlarni faylga saqlab qoyamiz
file_put_contents('sorov.txt', file_get_contents('php://input'));
//malumotlarni ózgaruvchiga saqlab olamiz
$tg = json_decode(file_get_contents('php://input'));
$xabar = $tg->message;
$xabar_matni = $xabar->text;
$chat_id = $xabar->chat->id;
$kimdan_id = $xabar->from->id;
$xabar_id = $xabar->message_id;
$ismi = $xabar->from->first_name;
$familyasi = $xabar->from->last_name;
$username = $xabar->from->username;
$toliq_ism = $ismi.' '.$familyasi;
if ($xabar_matni == "/start") {
file_put_contents('go.txt', file_get_contents('php://input'));
yozmoqda($chat_id, 'typing');
$matn = 'Salom botga xush kelibsiz';
tayota('sendMessage', [
'chat_id' => ''.$chat_id.'',
'parse_mode' => 'html',
'text' => 'salom'
]);
file_put_contents('ok.txt', file_get_contents('php://input'));
} else {
file_put_contents('log.txt', file_get_contents('php://input'));
}
3 daqiqa 10 soniyadan keyin yozdi:
Manashu ishlamayapti bironta xatolik ham kelmabdi logOut da
Oxiri negadur tg meni blokladi
{"ok":false,"error_code":401,"description":"Unauthorized"}