我有一个messenger bot webview,其中包含一个可供选择选项的表单,我遇到了使用beginShareFlow回复该帖子的问题。我为Webview添加了Messenger Extensions JS SDK。我该如何实现?任何链接真实世界的例子都很有用。
答案 0 :(得分:0)
撰写JSON消息以发送回线程,然后在用户共享按钮上单击或任何您想要的事件,运行MessengerExtensions.startShareFlow,传入函数以处理成功和错误事件,您创建的消息以及消息分享类型。在the docs
了解详情<script>
var messageToShare = {
"attachment":{
"type":"template",
"payload":{
"template_type":"generic",
"elements": [{
"title":"I took Peter's 'Which Hat Are You?' Quiz",
"image_url": "https://bot.peters-hats.com/img/hats/fez.jpg",
"subtitle": "My result: Fez",
"default_action":{
"type":"web_url",
"url": "https://bot.peters-hats.com/view_quiz_results.php?user=24601"
},
"buttons":[{
"type":"web_url",
"url":"https://bot.peters-hats.com/hatquiz.php?referer=24601",
"title":"Take the Quiz"
}]
}]
}
}
};
MessengerExtensions.beginShareFlow(function success(response) {
// Share successful
}, function error(errorCode, errorMessage) {
// The user was not able to share
},
messageToShare,
"broadcast");
</script>