1. Go to this page and download the library: Download grobolof/bot-payload 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 BotPayload\Telegram\ReplyMarkup\Model\Keyboard\Keyboard;
new ReplyMarkup(
keyboard: new Keyboard(buttonsPerRow: 2, resizeKeyboard: true, oneTimeKeyboard: true),
buttons: [
new Button(name: 'Да'),
new Button(name: 'Телефон', requestContact: true),
new Button(name: 'Гео', requestLocation: true),
],
);
new ReplyMarkup(
keyboard: new KeyboardInline(),
buttons: [
new Button(name: 'Открыть', row: 1, callbackData: 'open'),
new Button(name: 'Сайт', row: 2, url: 'https://example.com'),
],
);
use BotPayload\Telegram\ReplyMarkup\Model\Keyboard\KeyboardRemove;
new ReplyMarkup(keyboard: new KeyboardRemove());
// { "remove_keyboard": true }
use BotPayload\VK\Mapper\Model\Confirmation;
use BotPayload\VK\Mapper\VKMapper;
$event = VKMapper::exec($requestJson);
if ($event instanceof Confirmation) {
echo $confirmationToken; // строка из настроек сообщества, не JSON
return;
}
use BotPayload\VK\Mapper\Model\MessageNew;
$event = VKMapper::exec($requestJson);
if ($event instanceof MessageNew) {
$event->getPeerId(); // куда отвечать (messages.send)
$event->getFromId(); // кто написал
$event->getText(); // Привет
$event->getPayload(); // ['button' => 1] или null
$event->getObject()->getClientInfo()?->getInlineKeyboard(); // true
}