【问题标题】:How to send url link in the message using Telegram Bot or Show a button to open the URL link如何使用 Telegram Bot 在消息中发送 url 链接或显示按钮以打开 URL 链接
【发布时间】:2023-03-21 20:32:01
【问题描述】:

Bot 的消息文本为:

点击打开URL

网址是http://www.example.com/

参考图片为:

【问题讨论】:

    标签: telegram telegram-bot


    【解决方案1】:

    有两种方法可以让用户选择在 bot-message 中打开 URL:

    API 端点-https://api.telegram.org/bot{MENTION_YOUR_BOT_TOKEN*}/sendMessage

    API 方法-GET

    1. 在消息中显示 URL

    使用此原始 JSON 数据访问 API-

    {
        "chat_id" : MENTION_USER_CHAT_ID*,
        "text" : "Click to Open [URL](http://example.com)",
        "parse_mode" : "markdown"
    }
    
    1. 在消息下方显示 URL 按钮

    使用此原始 JSON 数据访问 API-

    {
        "chat_id" : MENTION_USER_CHAT_ID*,
        "text" : "Click to Open URL",
        "parse_mode" : "markdown",
        "reply_markup" : {
            "inline_keyboard" : [
                [
                    {
                        "text" : "Open link",
                        "url" : "http://example.com"
                    }
                ]
            ]
       }
    }
    

    注意:根据您的数据替换 * 标记的变量。

    【讨论】:

      猜你喜欢
      • 2018-09-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-10-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多