KeyboardButton
This object represents one button of the reply keyboard. At most one of the optional fields must be used to specify type of the button. For simple text buttons, String can be used instead of this object to specify the button text.
📝 Schema
Field | Type | Description |
---|---|---|
text | string | Text of the button. If none of the optional fields are used, it will be sent as a message when the button is pressed |
request_contact | Boolean | Optional. If True, the user's phone number will be sent as a contact when the button is pressed. Available in private chats only. |
request_location | Boolean | Optional. If True, the user's current location will be sent when the button is pressed. Available in private chats only. |
⚙️ Get methods
getText()
Retrieves the text of the button. If no optional fields are used, this text will be sent as a message when the button is pressed.
$text = $keyboardButtonObject->getText();
getRequestContact()
Checks if the button requests the user's phone number. Returns a boolean value: True
if the button requests the phone number, False
otherwise.
$requestContact = $keyboardButtonObject->getRequestContact();
getRequestLocation()
Checks if the button requests the user's current location. Returns a boolean value: True
if the button requests the location, False
otherwise.
$requestLocation = $keyboardButtonObject->getRequestLocation();
➕ More
tip
For further information, refer to the official Bale documentation for more details.