javascript - Facebook Send-to-Messenger Plugin not send welcome message to user -


https://developers.facebook.com/docs/messenger-platform/plugin-reference/send-to-messenger

i have searched on net issue didn't find solution it. have created "send messenger" button website integration , have created application in facebook developer.

i have added "messenger" product in application , working fine. application in live environment.

the problem when user clicked on "send messenger" button login dialog box open authentication after login have not receive welcome message in account.

below php code have used in webhook file hosted in secure server.

<?php // parameters $hubverifytoken = 'verify token'; $accesstoken = "my page access token";  // check token @ setup if ($_request['hub_verify_token'] === $hubverifytoken) {   echo $_request['hub_challenge'];   exit; }  $input = json_decode(file_get_contents('php://input'), true);  $sender = $input['entry'][0]['messaging'][0]['sender']['id'];  //api url $url = 'https://graph.facebook.com/v2.6/me/messages?access_token='.$accesstoken;  //initiate curl. $ch = curl_init($url);  //the json data. $json = '{ "setting_type":"call_to_actions", "thread_state":"new_thread", "call_to_actions":[      {       "message":{       "text":"welcome page!"      } } ] }';  //encode array json. $jsondataencoded = $json;  //tell curl want send post request. curl_setopt($ch, curlopt_post, 1);  //attach our encoded json string post fields. curl_setopt($ch, curlopt_postfields, $jsondataencoded);  //set content type application/json curl_setopt($ch, curlopt_httpheader, array('content-type: application/json'));  //execute request $result = curl_exec($ch);  ?> 

facebook button script

<script type="text/ecmascript">      window.fbasyncinit = function() {          fb.init({                  appid: "app_id",                  xfbml: true,                  version: "v2.6"          });      };      (function(d, s, id){                var js, fjs = d.getelementsbytagname(s)[0];                if (d.getelementbyid(id)) {                  return;                }                js = d.createelement(s);                js.id = id;                js.src = "//connect.facebook.net/en_us/sdk.js";                fjs.parentnode.insertbefore(js, fjs);              }(document, 'script', 'facebook-jssdk'));  </script>   <div class="fb-send-to-messenger" messenger_app_id="app_id" page_id="page_id" data-ref="" color="white" size="large"> </div>  

thanks help.


Comments

Popular posts from this blog

PHP and MySQL WP -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

go - golang pprof for c library code -