Messenger Webview在移动设备上无法在台式机上工作

时间:2018-06-20 12:57:25

标签: facebook chatbot facebook-messenger

我正在制作Messenger Webview示例,但它仅在移动设备上运行,而在桌面环境下却将我重定向到新标签页,

这是按钮的有效载荷,

    var buttons = [{
        type: "web_url",
        url: constant.SERVER_URL + "/checkout",
        title: "Yes",
        webview_height_ratio: "tall",
        messenger_extensions: false
    }]

这是请求方法,

app.get("/checkout", function (req, res) {
    let referer = req.get('Referer');
    console.log(referer)
    if (referer) {
        if (referer.indexOf('messenger') >= 0) {
            res.setHeader('X-Frame-Options', 'ALLOW-FROM https://www.messenger.com/');
        } else if (referer.indexOf('facebook') >= 0) {
            res.setHeader('X-Frame-Options', 'ALLOW-FROM https://www.facebook.com/');
        }
        res.render('checkout')
    }
});

1 个答案:

答案 0 :(得分:0)

if(result.length < 1) {
  res.send(404);
  return;
}

问题出在var buttons = [{ type: "web_url", url: constant.SERVER_URL + "/checkout", title: "Yes", webview_height_ratio: "tall", messenger_extensions: True }] 上,我做到了messenger_extensions,并且有效。