Viber Rest Api 无法打开内部浏览器
Viber Rest Api Cannot open Internal browser
我正在编写一个 Viber“键盘”,我想创建一个按钮,在内部浏览器中打开 link,根据此文档 doc should be done by sending JSON post to 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_"
}
有人知道如何解决这个问题或我做错了什么吗?
必须将参数 "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
}
]
}
}
我正在编写一个 Viber“键盘”,我想创建一个按钮,在内部浏览器中打开 link,根据此文档 doc should be done by sending JSON post to 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_"
}
有人知道如何解决这个问题或我做错了什么吗?
必须将参数 "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
}
]
}
}