1. Go to this page and download the library: Download uzdevid/php-telegram-bot library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
use uzdevid\telegram\bot\message\messages\methods\SendMessage;
$bot->sender()
->chatId(123456789) // yoki ->username('@uzdevid')
->method(new SendMessage('Salom. Bu matnli habar'))
->send();
use uzdevid\telegram\bot\message\messages\methods\SendPhoto;
$sendPhoto = new SendPhoto('https://uzdevid.com/img/logo.png');
$sendPhoto->caption('Bu rasmli habar')->hasSpoiler();
$bot->sender()
->chatId(123456789)
->method($sendPhoto)
->send();
use uzdevid\telegram\bot\message\messages\methods\SendMessage;
use uzdevid\telegram\bot\message\messages\keyboard\reply\ReplyButton;
use uzdevid\telegram\bot\message\messages\keyboard\reply\ReplyKeyboardMarkup;
use uzdevid\telegram\bot\message\messages\keyboard\reply\ReplyRow;
$replyMarkup = new ReplyKeyboardMarkup();
$replyMarkup->resizeKeyboard()->addRow(
(new ReplyRow())
->addButton(new ReplyButton('Tugma 1'))
->addButton((new ReplyButton('Joylashuv uchun tugma'))->requestLocation())
->addButton((new ReplyButton('Telefon raqam uchun tugma'))->requestContact())
);
$sendMessage = new SendMessage('Bu tugmali habar');
$sendMessage->addReplyMarkup($replyMarkup);
$bot->sender()
->chatId(123456789)
->method($sendMessage)
->send();
use uzdevid\telegram\bot\message\messages\methods\SendMessage;
use uzdevid\telegram\bot\message\messages\keyboard\reply\ReplyKeyboardRemove;
$sendMessage = new SendMessage('Bu oddiy habar');
$sendMessage->addReplyMarkup(new ReplyKeyboardRemove());