简体   繁体   English

Facebook 通过 Nexmo 的入站回复 API 在 PHP

[英]Facebook Inbound replies through Nexmo API in PHP

Am working on a facebook chat bot using Nexmos facebook message API with PHP.我正在使用 Nexmos facebook 消息 API 和 Z2FEC392304A5C2B37AC1 开发 facebook 聊天机器人I succeeded in sending a message in sandbox to facebook.我成功在沙箱中向 facebook 发送消息。 However, get a reply when through the inbound webhook call back is a hard nut now.但是,现在通过入站 webhook 回调很难获得回复。

NEXMO documentation is not that well detailed to help me get done with the TASK. NEXMO 文档没有那么详细,无法帮助我完成任务。 Any Help on how i can the reply message when a user on facebook replies to the page's chat?当 facebook 上的用户回复页面聊天时,我如何回复消息的任何帮助?

function inbound() {
        $this->load_model("Api_model")->save_inbound_prod_message($_POST);
    }

In that above code, i expected to have some data sent to me through $_POST however, the variable is empty.在上面的代码中,我希望通过 $_POST 向我发送一些数据,但是,变量是空的。

THank you for your help谢谢您的帮助

I had not mastered the art of PHP wit JSON data.我还没有掌握 PHP 和 JSON 数据的艺术。 So this was solved by these simple lines of code所以这通过这些简单的代码行解决了

$input = file_get_contents('php://input');
        //error_log($input);
        $input = json_decode($input);
        $psid = $input->from->id;

as you can see in the question, i expected the reply to be in $_POST variable which wasn't the case.正如您在问题中看到的那样,我希望回复在 $_POST 变量中,但事实并非如此。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM