@@ -110,8 +110,31 @@ Functions
110
110
111
111
For a complete and up-to-date functions documentation check http://eleirbag89.github.io/TelegramBotPHP/
112
112
113
- Build keyboard parameters
113
+ Build keyboards
114
114
------------
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
+
115
138
``` php
116
139
buildKeyBoard(array $options, $onetime=true, $resize=true, $selective=true)
117
140
```
0 commit comments