电报中的自定义键盘不起作用
custom keyboard in telegram doesn't work
我用 PHP 为 Telegram 机器人中的自定义键盘编写了这段代码,但是当代码执行它时 return 出现 400 错误请求错误);
有什么想法吗?
代码:
$botToken = "bot token";
$website = "https://api.telegram.org/bot".$botToken."/";
$Bot_reply=urlencode("Welcome");
$reply_markup = json_encode(
array(
"keyboard" => array(
array("[A]","[B]","[C]"),
array('[D]','[E]','[F]'),
array('[G]','[H]','[I]'),
),
"resize_keyboard" => true,
"one_time_keyboard" => true,
)
);
$url = $website."sendMessage?chat_id={$user_id}&reply_markup={$reply_markup}&text={$text}";
$callback = json_decode(file_get_contents($url), TRUE);
print_r($callback);
大家好谷歌搜索后我找到了答案
这很容易,我们应该将对象确定为数组
像这样
$reply_markup = json_encode(
array(
"keyboard" => array(
array(array(text =>"A"),array(text =>"b"),array(text =>"c")),
),
"resize_keyboard" => true,
"one_time_keyboard" => true,
)
);
我用 PHP 为 Telegram 机器人中的自定义键盘编写了这段代码,但是当代码执行它时 return 出现 400 错误请求错误);
有什么想法吗?
代码:
$botToken = "bot token";
$website = "https://api.telegram.org/bot".$botToken."/";
$Bot_reply=urlencode("Welcome");
$reply_markup = json_encode(
array(
"keyboard" => array(
array("[A]","[B]","[C]"),
array('[D]','[E]','[F]'),
array('[G]','[H]','[I]'),
),
"resize_keyboard" => true,
"one_time_keyboard" => true,
)
);
$url = $website."sendMessage?chat_id={$user_id}&reply_markup={$reply_markup}&text={$text}";
$callback = json_decode(file_get_contents($url), TRUE);
print_r($callback);
大家好谷歌搜索后我找到了答案
这很容易,我们应该将对象确定为数组
像这样
$reply_markup = json_encode(
array(
"keyboard" => array(
array(array(text =>"A"),array(text =>"b"),array(text =>"c")),
),
"resize_keyboard" => true,
"one_time_keyboard" => true,
)
);