Skip to content

Commit 354fcc5

Browse files
committed
Better doc for Keyboards
1 parent 391c896 commit 354fcc5

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

README.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,31 @@ Functions
110110

111111
For a complete and up-to-date functions documentation check http://eleirbag89.github.io/TelegramBotPHP/
112112

113-
Build keyboard parameters
113+
Build keyboards
114114
------------
115+
Telegram's bots can have two different kind of keyboards: Inline and Reply.
116+
The InlineKeyboard is linked to a particular message, while the ReplyKeyboard is linked to the whole chat.
117+
Both are an array of array of buttons, which rapresent the row and columns.
118+
For instance you can arrange a ReplyKeyboard like this:
119+
![ReplyKeabordExample](https://picload.org/image/rilclcwr/replykeyboard.png)
120+
using this code:
121+
```php
122+
$option = array( array($telegram->buildKeyboardButton("Button 1"), $telegram->buildKeyboardButton("Button 2")), array($telegram->buildKeyboardButton("Button 3"), $telegram->buildKeyboardButton("Button 4"), $telegram->buildKeyboardButton("Button 5")), array($telegram->buildKeyboardButton("Button 6")) );
123+
$keyb = $telegram->buildKeyBoard($option, $onetime=false);
124+
$content = array('chat_id' => $chat_id, 'reply_markup' => $keyb, 'text' => "This is a Keyboard Test");
125+
$telegram->sendMessage($content);
126+
```
127+
When a user click on the button, the button text is send back to the bot.
128+
For an InlineKeyboard it's pretty much the same (but you need to provide a valid URL or a Callback data)
129+
![InlineKeabordExample](https://picload.org/image/rilclcwa/replykeyboardinline.png)
130+
```php
131+
$option = array( array($telegram->buildInlineKeyBoardButton("Button 1", $url="http://link1.com"), $telegram->buildInlineKeyBoardButton("Button 2", $url="http://link2.com")), array($telegram->buildInlineKeyBoardButton("Button 3", $url="http://link3.com"), $telegram->buildInlineKeyBoardButton("Button 4", $url="http://link4.com"), $telegram->buildInlineKeyBoardButton("Button 5", $url="http://link5.com")), array($telegram->buildInlineKeyBoardButton("Button 6", $url="http://link6.com")) );
132+
$keyb = $telegram->buildInlineKeyBoard($option);
133+
$content = array('chat_id' => $chat_id, 'reply_markup' => $keyb, 'text' => "This is a Keyboard Test");
134+
$telegram->sendMessage($content);
135+
```
136+
This is the list of all the helper functions to make keyboards easily:
137+
115138
```php
116139
buildKeyBoard(array $options, $onetime=true, $resize=true, $selective=true)
117140
```

0 commit comments

Comments
 (0)