【问题标题】:how to create inline button for share message telegram bot php如何为共享消息电报bot php创建内联按钮
【发布时间】:2017-04-09 03:52:53
【问题描述】:

我有一条消息要添加内联按钮。单击此按钮时,用户可以将此消息转发给组。我该怎么做?

$keyboard = [
    'inline_keyboard' => [
    [['text' => 'forward me to groups']],
]];
HTTPRequest("sendMessage", [
    "chat_id" => $request["message"]["chat"]["id"],
    "text" => "this is a message",
    "reply_markup" => json_encode($keyboard)
]);

【问题讨论】:

  • 你能试着更清楚地解释一下这个按钮的作用吗?

标签: php bots telegram


【解决方案1】:

有一个我能想到的解决方案。根据Telegram API documentation,您可以传递一个名为switch_inline_query 的可选参数。这不是switch_inline_query 的应用程序,但它可以做你想做的事。您的代码将是这样的:

$keyboard = [
'inline_keyboard' => [
[['text' => 'forward me to groups'], 'switch_inline_query' => 'this is a message'],
]];
HTTPRequest("sendMessage", [
    "chat_id" => $request["message"]["chat"]["id"],
    "text" => "this is a message",
    "reply_markup" => json_encode($keyboard)
]);

按下内联按钮将提示用户选择他们的一个群组或聊天,打开该聊天并插入机器人的用户名和指定的消息:
@Yourbot This is a message
并按发送按钮消息将被发送。

【讨论】:

    猜你喜欢
    • 2018-02-04
    • 1970-01-01
    • 2017-02-14
    • 1970-01-01
    • 2020-06-17
    • 1970-01-01
    • 2021-08-27
    • 2018-11-17
    • 1970-01-01
    相关资源
    最近更新 更多