PHP code example of easy-keyboard / fluent-keyboard
1. Go to this page and download the library: Download easy-keyboard/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/ */
easy-keyboard / fluent-keyboard example snippets
$this->messages->sendMessage(
chat_id: 12345,
text: 'Keyboard Example',
reply_markup: KeyboardMarkup::new()
->singleUse()
->addButton(KeyboardButton::Text('Cancel'))
->addButton(KeyboardButton::Text('OK'))
->build()
);
KeyboardMarkup::new()
->placeholder('Placeholder')
->build();
KeyboardButton::Phone('Send my Contact');
InlineButton::Url('hello', 'https://example.com');
KeyboardMarkup::new()
->row(
KeyboardButton::Text('Cancel'),
KeyboardButton::Text('OK')
)
->build();
KeyboardInline::new()
->row(
InlineButton::Callback('1','page-1'),
InlineButton::Callback('2','page-2'),
InlineButton::Callback('3','page-3')
)
->row(
InlineButton::Callback('prev','page-prev'),
InlineButton::Callback('next','page-next')
)
->build();
KeyboardInline::new()
->addCallbacks([
'1' => 'page-1',
'2' => 'page-2',
'3' => 'page-3',
],[
'prev' => 'page-prev',
'next' => 'page-next'
])
->build();
KeyboardMarkup::new()
->addTexts([
'Cancel',
'Ok'
])
->build();
KeyboardMarkup::new()
->addButton(KeyboardButton::Text('First Button'))
->addButton(KeyboardButton::Text('Second Button'))
->build();
KeyboardInline::new()
->addButton(InlineButton::Callback('A', 'answer-a'))
->addButton(InlineButton::Callback('B', 'answer-b'))
->row()
->addButton(InlineButton::Callback('C', 'answer-c'))
->addButton(InlineButton::Callback('D', 'answer-d'))
->build();
KeyboardInline::new()
->addButton(InlineButton::Callback('A', 'answer-a'))
->addButton(InlineButton::Callback('B', 'answer-b'))
->row()
->addButton(InlineButton::Callback('C', 'answer-c'))
->addButton(InlineButton::Callback('D', 'answer-d'))
->remove()
->build();
$keyboard = KeyboardInline::new()
->addButton(InlineButton::Callback('Numbers', 'Numbers'))
->addButton(InlineButton::Callback('Status', 'Status'))
->row()
->addButton(InlineButton::Callback('Add', 'Add'))
->addButton(InlineButton::Callback('Remove', 'Remove'));
$keyboard->addToCoordinates(0, 1, InlineButton::Callback('Middle','Middle'));
$keyboard->replaceIntoCoordinates(1, 0, InlineButton::Callback('Replaced Add','Add'));
$keyboard->removeFromCoordinates(1, 0);
KeyboardInline::new()
->Stack(
InlineButton::Login('Login', 'https://example.com/login'),
InlineButton::Url('Visit Homepage', 'https://example.com')
)
->build();
#[FilterAnd(new FilterPrivate,new FilterIncoming)]
public function handleExit(Message $message){
$message->reply('Thank you',
reply_markup : KeyboardHide::new()->build()
);
}
$data['reply_markup'] = KeyboardForceReply::new()
->addButton(KeyboardButton::Text('Hello please reply'))
->placeholder('must reply')
->build();
KeyboardMarkup::new()
->addButton(KeyboardButton::Peer('Request for user', 0, RequestUser::new()));
KeyboardMarkup::new()
->addButton(KeyboardButton::Peer('Request for chat', 1, RequestGroup::new()));
KeyboardMarkup::new()
->addButton(KeyboardButton::Peer('Request for broadcast', 2, RequestChannel::new()));
KeyboardMarkup::new()
->requestUser('Request for user', 0);
KeyboardMarkup::new()
->requestGroup('Request for chat', 1);
KeyboardMarkup::new()
->requestChannel('Request for broadcast', 2);
$fluentKeyboard = Keyboard::fromRawReplyMarkup($replyMarkup);
$fluentKeyboard->addButton(InlineButton::Callback('End', 'End'));
#[FilterAnd(new FilterPrivate,new FilterIncoming)]
public function modify(Message $message){
$message->reply('That is new keyboard',
reply_markup : $fluentKeyboard->build()
);
}