【问题标题】:FB Messanger bot - can not make sending messages workFB Messenger 但 - 无法发送消息
【发布时间】: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


    【解决方案1】:

    也许你应该试试这样的 -

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

    【讨论】:

      猜你喜欢
      • 2013-10-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-01-08
      • 1970-01-01
      • 2016-08-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多