php - 无法通过 Telegram Bot API 发送带有标记的回复
问题描述
试图建立一个简单的机器人。这是我的代码:
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:点击
我应该如何解决这个问题?ty <3
解决方案
推荐阅读
- r - 更改多个列名,粘贴在列名的开头/结尾
- python - 当 x 值为日期时间时,如何使用 polyfit 获得最佳拟合曲线?
- sql-server - 在 MacBook OSX 上使用 SqlServer 优化 Docker 容器启动问题
- javascript - 使用 Javascript 一个接一个地添加 Django MultipleChoiceField
- amazon-web-services - How to expose external service for Jenkins installed using Helm in a k8s cluster?
- bash - 如何在 spinnaker-spinnaker-halyard-0 中运行多行命令
- java - 棉花糖上本机 WebView 中的 Instagram 链接
- layout - 具有框架 maxHeight 和 .infinity 的 SwiftUI 视图布局
- java - 如何用逗号分隔每个数组元素(使用 replaceAll )?
- java - 将 RGB byte[][] 图像转换为 byte[] 的最佳方法