2016-12-25 97 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);