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);
}
我將如何去審查過程來做到這一點? –
如果您的機器人已準備就緒,您可以發送評論請求到fb,如步驟#7所示,在此lnkhttps://blog.hartleybrody.com/fb-messenger-bot/ –
中,您可以從fb文檔中閱讀https://developers.facebook .COM /文檔/信使平臺/應用程序審查 –