2016-12-05 23 views
0

我的Facebook機器人回覆只有頁面的作者,但沒有網頁作者它不回答對方的回答誰是發送消息給我page.I找不到this.My代碼的任何解決方案如下:爲什麼我的臉書機器人不能播放所有發送信息到我的頁面的人?

<?php 
     $challenge = $_REQUEST['hub_challenge']; 
     $verify_token = $_REQUEST['hub_verify_token']; 

     $accessToken = "mytokem is here"; 

     // Set this Verify Token Value on your Facebook App 
     if ($verify_token === 'Verifytoken') { 
     echo $challenge; 
     } 
    $input = json_decode(file_get_contents('php://input'), true); 
    // Get the Senders Graph ID 
    $sender = $input['entry'][0]['messaging'][0]['sender']['id']; 
    // Get the returned message 
    $message = $input['entry'][0]['messaging'][0]['message']['text']; 
    echo $message; 
    //API Url and Access Token, generate this token value on your Facebook App Page 
    $url = 'https://graph.facebook.com/v2.6/me/messages?   access_token='.$accessToken; 
    //Initiate cURL. 
     $ch = curl_init($url); 
    //The JSON data. 
    $jsonData = '{ 
     "recipient":{ 
      "id":"' . $sender . '" 
     }, 
     "message":{ 
      "text":"hello user" 
     } 
     }'; 
     //Tell cURL that we want to send a POST request. 
     curl_setopt($ch, CURLOPT_POST, 1); 
     //Attach our encoded JSON string to the POST fields. 
     curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonData); 
     //Set the content type to application/json 
     curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:   application/json')); 
     //Execute the request but first check if the message is not empty. 
     if(!empty($input['entry'][0]['messaging'][0]['message'])){ 
      $result = curl_exec($ch); 
     } 

回答

0

你FB測試模式下的bot應用程序? 您的fb應用程序通過Facebook批准。 如果應用程序在測試,然後只有管理員或測試人員能夠使用機器人。

在你的機器人向世界開放之前,你必須經歷審查過程,隨時與任何人聊天。

+0

我將如何去審查過程來做到這一點? –

+1

如果您的機器人已準備就緒,您可以發送評論請求到fb,如步驟#7所示,在此lnkhttps://blog.hartleybrody.com/fb-messenger-bot/ –

+0

中,您可以從fb文檔中閱讀https://developers.facebook .COM /文檔/信使平臺/應用程序審查 –

相關問題