Telegram Bot Inline Keyboard不显示PHP(Telegram Bot Inline Keyboard not displaying PHP)

编程入门 行业动态 更新时间:2024-10-23 17:33:15
Telegram Bot Inline Keyboard不显示PHP(Telegram Bot Inline Keyboard not displaying PHP)

以下代码有效,它添加了自定义键盘键'Button1'和'Button2'

$keyboard = [ 'keyboard' => [['Button1'],['Button2']], 'resize_keyboard' => true, 'one_time_keyboard' => true, 'selective' => true ]; $keyboard = json_encode($keyboard, true); $sendto = API_URL."sendmessage?chat_id=".$chatID."&text=".$reply."&parse_mode=HTML&reply_markup=$keyboard";

我需要使用内联键盘作为我的目的,但我无法让它工作

$keyboard = [ 'inline_keyboard' => [['Button1' => 'test', 'callback_data' => 'test'], ];

要么

$keyboard = [ 'inline_keyboard' => [['Button1' => 'test'],['callback_data' => 'test']], ];

不起作用。 我真的很感激,如果有人有一个工作的例子,或者可以指出我的例子中有什么问题。

链接到文档: https : //core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating

The following code works, it adds custom keyboard keys 'Button1' and 'Button2'

$keyboard = [ 'keyboard' => [['Button1'],['Button2']], 'resize_keyboard' => true, 'one_time_keyboard' => true, 'selective' => true ]; $keyboard = json_encode($keyboard, true); $sendto = API_URL."sendmessage?chat_id=".$chatID."&text=".$reply."&parse_mode=HTML&reply_markup=$keyboard";

I need to use Inline Keyboard though for my purposes, but I haven't been able to get it to work

$keyboard = [ 'inline_keyboard' => [['Button1' => 'test', 'callback_data' => 'test'], ];

or

$keyboard = [ 'inline_keyboard' => [['Button1' => 'test'],['callback_data' => 'test']], ];

doesn't work. I would really appreciate if anyone has a working example or can point out what is wrong in my example.

Link to documentation: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating

最满意答案

看起来你错过了一个额外的数组。 reply_markup应如下所示:

$keyboard = array( "inline_keyboard" => array(array(array("text" => "My Button Text", "callback_data" => "myCallbackData"))) );

It looks like you are missing an additional array. The reply_markup should look like this:

$keyboard = array( "inline_keyboard" => array(array(array("text" => "My Button Text", "callback_data" => "myCallbackData"))) );

更多推荐

本文发布于:2023-07-19 01:05:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1169688.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Inline   Bot   Telegram   displaying   PHP

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!