【发布时间】:2017-05-10 03:20:17
【问题描述】:
我正在制作一个 FB Messenger 机器人。我无法让机器人发送消息恢复工作。
我正在为 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);
你能发现任何问题吗? :-) 感谢您抽出宝贵时间。
【问题讨论】:
标签: php facebook api facebook-graph-api bots