2016-12-25 27 views
1

我正在製作一個FB信使機器人。我無法讓機器人發送消息返回工作。FB Messanger機器人 - 無法使發送信息工作

我爲Webhook使用Heroku。

我下面這個教程:https://www.youtube.com/watch?v=__SWFhHocDI

這裏是我的代碼(我改變了令牌變量,我不使用真正的令牌):

file_put_contents('fb.txt', file_get_contents('php://input')); 

$fb = file_get_contents('fb.txt'); 

$fb = json_decode($fb); 

$rid = $fb->entry[0]->messaging[0]->sender->id; 

$token = "MYTOKEN"; 

$data = array(
     'recipient' => array('id'=>"$rid"), 
     'message' => array('text'=>"Nice to meet you!") 
); 

$options = array(
      'http' => array(
        'method' => 'POST', 
        'content' => json_encode($data), 
        'header' => "Content-Type: application/json\n" 
     ) 
); 

$context = stream_context_create($options); 

file_get_contents("https://graph.facebook.com/v2.8/me/subscribed_apps?access_token=$token", false, $context); 

你能發現什麼問題? :-)謝謝你抽出時間。

回答

0

也許你應該嘗試這樣的事情 -

file_get_contents("https://graph.facebook.com/v2.6/me/messages?access_token=$token", false, $context); 
相關問題