2017-04-09 3 views
1

私はメッセンジャーボットwebviewを選択するオプションを持つフォームを持っています。私はbeginShareFlowを使ってメッセージに問題があります。 Messenger Extensions JS SDKをWebview用に追加しました。これをどのように実装するのですか?実際のリンクの例は参考になります。メッセンジャーボットWebview beginShareFlow not working

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