Skip to content

Instantly share code, notes, and snippets.

@CasperLaiTW
Last active December 16, 2016 17:57
Show Gist options
  • Save CasperLaiTW/a52b8f9d7e7e0a0200b2c1df98231854 to your computer and use it in GitHub Desktop.
Save CasperLaiTW/a52b8f9d7e7e0a0200b2c1df98231854 to your computer and use it in GitHub Desktop.
Messenger webview bug
curl -X POST -H "Content-Type: application/json" -d '{
  "recipient":{
    "id":"USER_ID"
  },
  "message":{
    "attachment":{
      "type":"template",
      "payload":{
        "template_type":"button",
        "text":"Hi, go to webview",
        "buttons":[
          {
            "type":"web_url",
            "url":"https://{your-domain}/index.html",
            "title":"Show Website",
            "webview_height_ratio": "full",
            "messenger_extensions": true,
          },
        ]
      }
    }
  }
}' "https://graph.facebook.com/v2.6/me/messages?access_token=PAGE_ACCESS_TOKEN"
<html>
<head>
<title>Show Messenger is Supported</title>
</head>
<body>
Messenger Extension is Supported: <span id="isSupported"></span>
<script>
(function (d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {
return;
}
js = d.createElement(s);
js.id = id;
js.src = "//connect.facebook.com/en_US/messenger.Extensions.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'Messenger'));
window.extAsyncInit = function () {
var isSupported = MessengerExtensions.isInExtension();
document.getElementById('isSupported').innerText = isSupported;
};
</script>
</body>
</html>
curl -X POST -H "Content-Type: application/json" -d '{
  "setting_type" : "call_to_actions",
  "thread_state" : "existing_thread",
  "call_to_actions":[
    {
      "type":"web_url",
      "url":"https://{your-domain}/index.html",
      "title":"Show Website",
      "webview_height_ratio": "full",
      "messenger_extensions": true,
    }
  ]
}' "https://graph.facebook.com/v2.6/me/thread_settings?access_token=PAGE_ACCESS_TOKEN"
@CasperLaiTW
Copy link
Author

Button Template Result:

button template

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment