Yangi formatda davom etish uchun: https://uzfor.net/view.php?id=3446&page=4
PHP dasturlash tilida Telegram bot yozish
Mavzu fayllari (5)
Xabarlar
DjHuSo, demak functiondagi fuktsiyalardan foydalanib qoshimcha rasm yoki yangiliklarni ham yuborish mumkin shundaymi
30 martdan boshlab telegram api bilan ishlash o'zgardimi?
Telegram bot bilan sayt ni aloqasi uzildi.
Telegram bot bilan sayt ni aloqasi uzildi.
WapUsta, # WapUsta (02.04.2020 / 23:10)
30 martdan boshlab telegram api bilan ishlash o'zgardimi?
Telegram bot bilan sayt ni aloqasi uzildi.Ishlayapti muammosiz avvalgiday
30 martdan boshlab telegram api bilan ishlash o'zgardimi?
Telegram bot bilan sayt ni aloqasi uzildi.Ishlayapti muammosiz avvalgiday
Shaxsan o`zim telegram botda php curldan emas Guzzle, PHP HTTP client da yozishni boshladim. Tezligi ancha yaxshi bo`lar ekan.
Guzledagi botga namuna:
Guzledagi botga namuna:
<?php require_once( 'vendor/autoload.php' ); use GuzzleHttp\Client; $apiKey = '<TOKEN>'; // Put your bot's API key here $apiURL = 'https://api.telegram.org/bot' . $apiKey . '/'; $chatid = $update->message->chat->id; $type = $update->message->chat->type; $lastname = $update->message->chat->last_name; $fristname = $update->message->chat->first_name; $keyboard2 = json_encode(['inline_keyboard' => [[['url' => 'https://t.me/convertor_group', 'text' => 'Guruhga qo`shilish'], ], [['url' => 'https://uzhackersw.uz/', 'text' => 'Saytga kirish'], ], ], ]); $keyboard = json_encode(['inline_keyboard' => [[['url' => 'https://t.me/convertor_group', 'text' => 'Guruhimiz'], ], [['url' => 'https://uzhackersw.uz/', 'text' => 'Saytga kirish'], ], ], ]); $akbarali = '<ADMIN_ID>'; $guruhim = '<CHAT_ID>'; if ( $update->message->text == 'Hello' ){ } if ( $update->message->text == 'file' ){ } if ( $update->message->text == '/start' ){ 'chat_id' => $chatid, 'text' => "Salom " . $fristname. " " .$lastname . ". Men JPG rasmni PDF qilish sizga tashlash uchun @kbarali tomonidan yozildim. Menga rasm tashlashdan oldin /boshla buyrug`ini bering. Keyin JPG rasmni PHOTO qilish tashlang (file qilib emas)!", 'parse_mode' => 'html', 'reply_markup' => $keyboard2))); }
+ (1): Fokuschi,
Shu tushunarsiz harflarni, kril alefboridagi harflarni o'rniga boshqa shtrixlangan kodni ochishni buyursakchi.
Lekin unga SSL Sertifikat bermasa kerak a ;-)
Hackerlar shtrixlangan yozishmalarni qanday o'qishi endi ma'lum.
Maqolaga gap yo'q. Zo'r
Lekin unga SSL Sertifikat bermasa kerak a ;-)
Hackerlar shtrixlangan yozishmalarni qanday o'qishi endi ma'lum.
Maqolaga gap yo'q. Zo'r
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"}
Tavsiya etamiz:
- Hoziroq maydonlarni to'ldiring va reklamangizni joylashtiring!
Mavzuga oid xabarlar soni: 71 ta
So'ngi faollik vaqti: 21:37:47, 16 Sep 2021