【问题标题】:Messenger Bot Webview beginShareFlow not workingMessenger Bot Webview beginShareFlow 不工作
【发布时间】:2017-09-04 18:43:35
【问题描述】:

我有一个信使机器人webview 带有一个可以选择的表单,我在使用 beginShareFlow 将消息返回到线程时遇到问题。我为 Webview 添加了 Messenger Extensions JS SDK。我该如何实施?任何链接现实世界的例子都是有帮助的。

【问题讨论】:

  • 请提供一些代码!

标签: facebook webview bots chatbot messenger


【解决方案1】:

编写一个 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>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-08-22
    • 1970-01-01
    • 1970-01-01
    • 2016-11-11
    • 2017-10-05
    • 1970-01-01
    相关资源
    最近更新 更多