'Can't send reply with markup by Telegram Bot API
Trying to build up a simple bot. Here's my code:
require 'vendor/autoload.php';
use Telegram\Bot\Api;
$telegram = new Api('<MY TOKEN>');
$result = $telegram -> getWebhookUpdates();
$text = $result["message"]["text"];
$chat_id = $result["message"]["chat"]["id"];
$name = $result["message"]["from"]["username"];
$keyboard = [["news"],["more news"],["loolz"]];
if ($text == "/start") {
$reply = "Hello there!";
$reply_markup = $telegram->replyKeyboardMarkup([ 'keyboard' => $keyboard, 'resize_keyboard' => true, 'one_time_keyboard' => false ]);
$telegram->sendMessage([ 'chat_id' => $chat_id, 'text' => $reply, 'reply_markup' => $reply_markup ]);
}
if ($text == "/btn1") {
$reply = "AWESOME! YOU TAPPED 2nd BUTTON :)";
$telegram->sendMessage([ 'chat_id' => $chat_id, 'text' => $reply ]);
}
Condition if ($text == "/btn1") works, but it stops when i add $reply_markup to "btn1" action.
Accordingly, the first condition also does not work due to $reply_markup
This SDK used in my project: click
How should i fix this? ty <3
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
