[英]How can I make a botman URL button for facebook messenger that acts as a webview?
我使用botman作为制作Messenger bot的插件。 我有打开Web URL的这段代码,但是我想要使其成为WebView。 这是我的代码:
$botman->hears('try', function ($bot) {
$bot->typesAndWaits(2);
$bot->reply(ListTemplate::create()
->useCompactView()
->addElement(
Element::create('Sample Title')
->subtitle('Some subtitle.')
->image('https://sampleurl.com/images/logo.png')
->addButton(ElementButton::create('Sample Button')
->url('https://sampleurl.com')
)
)
);
});
上面的代码有效,但是它在新标签页中打开了网址。 我喜欢它的行为就像一个Web视图,就像我在持久菜单中创建的一样:
'persistent_menu' => [
[
'locale' => 'default',
'composer_input_disabled' => 'false',
'call_to_actions' => [
[
'title' => 'Sample Title',
'type' => 'web_url',
'url' => 'https://sampleurl.com',
'webview_height_ratio' => 'full',
'webview_share_button' => 'hide',
'messenger_extensions' => true
],
],
],
],
您需要像这样使用enableExtensions()
方法。 它告诉FB请求允许通过按钮或菜单进行Web视图。
When you are opening the webview from the persistent menu or a button, ensure that the messenger_extensions parameter is set to true. If a user has opened the webview via a shared message, it is not required that they have talked to your bot for Messenger Extensions to work.
(来自FB Docs)
ButtonTemplate::create('Open Webview')
->addButton(ElementButton::create('Click here')
->url(https://myurl.com/webview')
->enableExtensions()
);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.