尝试构建一个简单的机器人。 这是我的代码:
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 ]);
}
条件if ($text == "/btn1")
可以工作,但是当我将$reply_markup
添加到“ btn1”操作中时它会停止。
因此,由于$reply_markup
我的项目中使用了以下SDK:click
我该如何解决? ty <3