【问题标题】:Viber Rest Api Cannot open Internal browserViber Rest Api 无法打开内部浏览器
【发布时间】:2023-03-29 03:43:01
【问题描述】:

我正在编写一个 Viber“键盘”,我想创建一个在内部浏览器中打开链接的按钮,根据此文档 doc 应该通过将 JSON 帖子发送到 https://chatapi.viber.com/pa/send_message 来完成。我正在设置按钮的参数“ActionType”:“open-url”和“ActionBody”:“example.com”。参数 "OpenURLType": "internal" 是可选的,默认值为 internal。不管我写什么作为这个参数的值,或者如果我省略它,响应是成功的,但是 url 在外部浏览器中打开。

{
    "receiver":"some hash",
    "keyboard":{
      "Type":"keyboard",
      "DefaultHeight":false,
     "Buttons": [
            {
                "Columns": null,
                "Rows": null,
                "BgColor": "#7eceea",
                "Silent": null,
                "BgMediaType": null,
                "BgMedia": null,
                "BgMediaScaleType": null,
                "ImageScaleType": null,
                "BgLoop": null,
                "ActionType": "open-url",
                "ActionBody": "https://www.wikipedia.org/",
                "Image": null,
                "Text": "open this ",
                "TextVAlign": null,
                "TextHAlign": null,
                "TextPaddings": null,
                "TextOpacity": null,
                "TextSize": "small",
                "OpenURLType": "internal",
                "OpenURLMediaType": "nulll",
                "TextBgGradientColor": null,
                "TextShouldFit": null
            }
        ]
   }
}

然后响应 200 OK

{
"status": 0,
"status_message": "ok",
"message_token": 5469236575712199350,
"chat_hostname": "SN-CHAT-01_"

}

当我使用其他可选参数时,我注意到不一致。当您提供一些乱码值(例如将 ActaionType 设置为“operghj”)时,其中一些会产生错误。其他可选参数没有。例如

{
    "status": 3,
    "status_message": "keyboard is not valid. [instance value (\"operghj\") not found in enum (possible values: [\"reply\",\"open-url\",\"\"])]",
    "chat_hostname": "SN-CHAT-01_"
}

有人知道如何解决这个问题或我做错了什么吗?

【问题讨论】:

    标签: spring api rest viber viber-api


    【解决方案1】:

    参数"min_api_version": 7,必须添加到json中,以便在内部打开url。

    {
        "receiver":"some hash",
        "min_api_version": 7,
        "keyboard":{
          "Type":"keyboard",
          "DefaultHeight":false,
         "Buttons": [
                {
                    "Columns": null,
                    "Rows": null,
                    "BgColor": "#7eceea",
                    "Silent": null,
                    "BgMediaType": null,
                    "BgMedia": null,
                    "BgMediaScaleType": null,
                    "ImageScaleType": null,
                    "BgLoop": null,
                    "ActionType": "open-url",
                    "ActionBody": "https://www.wikipedia.org/",
                    "Image": null,
                    "Text": "open this ",
                    "TextVAlign": null,
                    "TextHAlign": null,
                    "TextPaddings": null,
                    "TextOpacity": null,
                    "TextSize": "small",
                    "OpenURLType": "internal",
                    "OpenURLMediaType": "nulll",
                    "TextBgGradientColor": null,
                    "TextShouldFit": null
                }
            ]
       }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-07-13
      • 2017-08-07
      • 1970-01-01
      • 2021-06-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-08-28
      相关资源
      最近更新 更多