PHP code example of php-telegram-bot / fluent-keyboard
1. Go to this page and download the library: Download php-telegram-bot/fluent-keyboard 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/ */
php-telegram-bot / fluent-keyboard example snippets
Request::sendMessage([
'chat_id' => 12345,
'text' => 'Keyboard Example',
'reply_markup' => ReplyKeyboardMarkup::make()
->oneTimeKeyboard()
->button(KeyboardButton::make('Cancel'))
->button(KeyboardButton::make('OK')),
]);
ReplyKeyboardMarkup::make()
->inputFieldPlaceholder('Placeholder');
KeyboardButton::make()
->text('Send my Contact')
->requestContact();
KeyboardButton::make('Send my Location')
->requestLocation();
InlineKeyboardButton::make('Login')
->loginUrl(['url' => 'https://example.com']);
ReplyKeyboardMarkup::make()
->row([
KeyboardButton::make('Cancel'),
KeyboardButton::make('OK')
]);
InlineKeyboardMarkup::make()
->row([
InlineKeyboardButton::make('1')->callbackData('page-1'),
InlineKeyboardButton::make('2')->callbackData('page-2'),
InlineKeyboardButton::make('3')->callbackData('page-3')
])
->row([
InlineKeyboardButton::make('prev')->callbackData('page-prev'),
InlineKeyboardButton::make('next')->callbackData('page-next')
]);
ReplyKeyboardMarkup::make()
->button(KeyboardButton::make('First Button'))
->button(KeyboardButton::make('Second Button'));
InlineKeyboardMarkup::make()
->button(InlineKeyboardButton::make('A')->callbackData('answer-a'))
->button(InlineKeyboardButton::make('B')->callbackData('answer-b'))
->row()
->button(InlineKeyboardButton::make('C')->callbackData('answer-c'))
->button(InlineKeyboardButton::make('D')->callbackData('answer-d'));
InlineKeyboardMarkup::make()
->stack([
InlineKeyboardButton::make('Login')->loginUrl('https://example.com/login'),
InlineKeyboardButton::make('Visit Homepage')->url('https://example.com')
]);
$this->replyToUser('Thank you', [
'reply_markup' => ReplyKeyboardRemove::make()->selective(),
]);
$data['reply_markup'] = ForceReply::make()->inputFieldPlaceholder('Please type something...');
KeyboardButton::make()->requestPoll(KeyboardButtonPollType::regular())
$pollButton = new KeyboardButtonPollType([
'type' => 'quiz'
]);