Codeigniter-Botman-回复方法不起作用

时间:2018-07-31 19:23:21

标签: php codeigniter chatbot facebook-chatbot

我正在使用Botman 2.0和Codeigniter 3.1.6

我的所有者服务器已成功设置HTTPS和FB Webhook。

我如何使用Codeigniter设置项目?因为,我成功设置了FB Webhook设置,但是,当我在Messenger上键入“ hi”时,此响应不会答复。

您能为我的聊天机器人正常工作提供一些建议吗?

注意1:我已经使用PHP(无框架)进行了测试,并且可以正常工作。

注意2:我已经用NodeJS测试过,并且可以正常工作。

enter image description here

use BotMan\BotMan\BotMan;
use BotMan\BotMan\BotManFactory;
use BotMan\BotMan\Drivers\DriverManager;

class Facebook_messenger extends CI_Controller {

    function __construct()
    {
        parent::__construct();

    }

    public function bot(){
        $config = [
            // Your driver-specific configuration
            'facebook' => [
                'token' => 'EAAZA1UK2sl8UBAIueLY2ZCHraasS3E52AS37wUVypMLQatW5taE71LByyl3nWNau8uTKYs1aw11lQXpDOfPrrQE8BLWf6PZBkwuQIdzea7lMeZCc4jCiZCqhKZABKnc2V8FNabVbHF9J6opkb6MCsBAxnqO0kDsgeoYV88gNOIJuTZAr9T7pzoBAZC',
                //'app_secret' => 'f1a032fb00484a59c0322617b7623745a',
                'verification'=>'xxxxapp',
            ]
        ];

        // Load the driver(s) you want to use
        DriverManager::loadDriver(\BotMan\Drivers\Facebook\FacebookDriver::class);

        // Create an instance
        $botman = BotManFactory::create($config);


        // Give the bot something to listen for.
        $botman->hears('hi', function (BotMan $bot) {
            $bot->reply('Hello');
        });

        $botman->hears('delayed', function (BotMan $bot) {
            $bot->reply('Field will remain in yellow (delayed)unless a game is scheduled on it.');
        });

        $botman->hears('canceled', function (BotMan $bot) {
            $bot->reply('Games cancelled due to poor field conditions.');
        });

        // Start listening
        $botman->listen();
    }

}

0 个答案:

没有答案