电报PHP创建键盘

电报PHP创建键盘,php,keyboard,bots,telegram,Php,Keyboard,Bots,Telegram,有人能帮我解决这个代码中的问题吗? 我想在电报机器人上有3个按钮。 这是execute.php文件,如果我在参数中放置的reply\u标记不起作用 <?php $content = file_get_contents("php://input"); $update = json_decode($content, true); if(!$update) { exit; } $message = isset($update['message']) ? $update['message'

有人能帮我解决这个代码中的问题吗? 我想在电报机器人上有3个按钮。 这是execute.php文件,如果我在参数中放置的reply\u标记不起作用

<?php
$content = file_get_contents("php://input");
$update = json_decode($content, true);

if(!$update)
{
  exit;
}

$message = isset($update['message']) ? $update['message'] : "";
$messageId = isset($message['message_id']) ? $message['message_id'] : "";
$chatId = isset($message['chat']['id']) ? $message['chat']['id'] : "";
$firstname = isset($message['chat']['first_name']) ? $message['chat']['first_name'] : "";
$lastname = isset($message['chat']['last_name']) ? $message['chat']['last_name'] : "";
$username = isset($message['chat']['username']) ? $message['chat']['username'] : "";
$date = isset($message['date']) ? $message['date'] : "";
$text = isset($message['text']) ? $message['text'] : "";

$text = trim($text);
$text = strtolower($text);

header("Content-Type: application/json");
$response = '';
$encodedMarkup = '';

$list=array("A", "B", "C");
$response="Choose:";
global $bottoken;
$replyMarkup = array(
    'keyboard' => list,
);
$encodedMarkup = json_encode($replyMarkup);

$parameters = array('chat_id' => $chatId, 'text' => $response, 'reply_markup' => $encodedMarkup);
$parameters["method"] = "sendMessage";
echo json_encode($parameters);
这是错误的:

list=array("A", "B", "C");
不能为常量赋值。您只能
define()
常量,例如

define('list', array('A', 'B', 'C'));
也许你是说

$list=array("A", "B", "C");
^--
相反?

试试这个

$list = array(array("A", "B", "C"));
$replyMarkup = array("keyboard" => $list,"resize_keyboard" => false,"one_time_keyboard" => false);
$encodedMarkup = json_encode($replyMarkup);

是的,复制/粘贴时出错。但它还不起作用。