Telegram-API-PHP bu telegram messenjerida oson bot uchish uchun yozilgan open source code. Bu orqali siz istalgancha o'zingizga telegram botlari ochishingiz mumkin va juda oson.
Loyiha katalogidan ishga tushiring:
https://github.com/shoxruxrashidov/Telegram-API-PHP.git
Download tugmachasiga bosing va yuklab oling
TelegramBot.php-ni serveringizga nusxalash va uni yangi bot skriptingizga qo'shish kerak bo'ladi:
include 'Telegram.php';
$telegram = new TelegramBot();
$telegram->setToken('Sizning tokeningiz');
Eslatma: Webhook faqat bir maratta connect qilinadi.
echo $telegram->setWebhook('saytingiz manzili');
require_once 'TelegramBot.php';
$telegram = new TelegramBot();
$telegram->setToken('sizning token');
$data = $telegram->getData();
Avto javob berish
if ($data->text == 'salom'){
$telegram->sendMessage('Salom Qalesiz?');
}
Fotosurat yuborish
if ($data->text == 'rasim yubor' || $data->text == 'rasim jonat'){
$telegram->sendPhoto('https://www.fotor.com/ru/loopBannerImg/ru-homeloop2.jpg','senga rasim kerakmi ol ana bolmasa');
}
Menyu bilan xabar yuborish
if ($data->text == 'menu' || $data->text == 'default-menu'){
$menu = $this->bot->buildKeyBoard([['🏠 Bosh Saxifa']], $onetime = false, true);
$telegram->sendMessage('Test Menu',$menu);
}