2017-04-09 136 views
1

我有一个messenger bot webview带有选项的选项,我有一个使用beginShareFlow返回到线程的问题。我为Webview添加了Messenger Extensions JS SDK。我如何实现这个?任何链接真实世界的例子都很有用。Messenger Bot Webview beginShareFlow不工作

+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>