TelegramPHP Documentation

InlineKeyboard
in package
implements JsonSerializable

FinalYes

Builds the `InlineKeyboardMarkup` attached under a message - the buttons that stay with the message rather than replacing the user's keyboard.

$telegram->sendMessage($chatId, 'Deploy?', reply_markup: InlineKeyboard::new()
    ->callback('Ship it', 'deploy:yes')
    ->callback('Hold', 'deploy:no')
    ->row()
    ->url('What changed', 'https://example.com/diff'));

Buttons land in the current row; row() starts the next one.

Tags
link
https://core.telegram.org/bots/api#inlinekeyboardmarkup
author

Valithor Obsidion valithor@valgorithms.com

Table of Contents

Interfaces

JsonSerializable

Properties

$rows  : array<int, array<int, array<string, mixed>>>

Methods

button()  : self
Adds a button built by hand, for the fields the named helpers do not cover.
callback()  : self
A button that sends `callback_data` back as a callback query.
copyText()  : self
A button that copies text to the user's clipboard.
game()  : self
A button that opens a game. One per message, and it must be the first button.
jsonSerialize()  : array{inline_keyboard: list>>}
login()  : self
A button that logs the user in to your site through Telegram.
new()  : self
pay()  : self
The pay button for an invoice. One per message, and it must be the first button.
row()  : self
Starts a new row. A row that would be left empty is dropped on serialisation.
switchInline()  : self
A button that drops the bot's username and a query into a chat the user picks.
url()  : self
A button that opens a URL.
webApp()  : self
A button that launches a Mini App.

Properties

$rows

private array<int, array<int, array<string, mixed>>> $rows = [[]]

Methods

button()

Adds a button built by hand, for the fields the named helpers do not cover.

public button(array<string, mixed> $button) : self
Parameters
$button : array<string, mixed>
Return values
self

callback()

A button that sends `callback_data` back as a callback query.

public callback(string $text, string $data) : self
Parameters
$text : string
$data : string
Return values
self

copyText()

A button that copies text to the user's clipboard.

public copyText(string $text, string $copy) : self
Parameters
$text : string
$copy : string
Return values
self

game()

A button that opens a game. One per message, and it must be the first button.

public game(string $text) : self
Parameters
$text : string
Return values
self

jsonSerialize()

public jsonSerialize() : array{inline_keyboard: list>>}
Return values
array{inline_keyboard: list>>}

login()

A button that logs the user in to your site through Telegram.

public login(string $text, string $url[, ?string $forwardText = null ][, ?string $botUsername = null ][, ?bool $requestWriteAccess = null ]) : self
Parameters
$text : string
$url : string
$forwardText : ?string = null
$botUsername : ?string = null
$requestWriteAccess : ?bool = null
Return values
self

pay()

The pay button for an invoice. One per message, and it must be the first button.

public pay(string $text) : self
Parameters
$text : string
Return values
self

row()

Starts a new row. A row that would be left empty is dropped on serialisation.

public row() : self
Return values
self

switchInline()

A button that drops the bot's username and a query into a chat the user picks.

public switchInline(string $text[, string $query = '' ][, bool $currentChat = false ]) : self
Parameters
$text : string
$query : string = ''
$currentChat : bool = false
Return values
self

url()

A button that opens a URL.

public url(string $text, string $url) : self
Parameters
$text : string
$url : string
Return values
self

webApp()

A button that launches a Mini App.

public webApp(string $text, string $url) : self
Parameters
$text : string
$url : string
Return values
self
On this page

Search results