当我尝试基于Botman为我的messenger机器人设置webhook时,我得到了以下错误:“无法验证URL。响应与质询不匹配,预期的value=...”。
这个问题似乎与Botman有关,因为在其他PHP bot上设置webhook没有任何问题。
我尝试过将我的机器人同时放在本地主机(使用Botman文档中建议的ngrok )和使用https和ssl的公共主机上--这些都不起作用。我已经尝试了在https://christoph-rumpel.com/2017/09/botman-quick-tip-how-to-debug-facebook-webhook-errors/找到的解决方案,但没有成功。
下面是我的代码:
require __DIR__ . '/vendor/autoload.php';
use BotMan\BotMan\BotMan;
use BotMan\BotMan\BotManFactory;
use BotMan\BotMan\Drivers\DriverManager;
$config = [
'facebook' => [
'token' => 'my_token',
'app_secret' => 'my_secret',
'verification'=>'my_verification',
]
];
DriverManager::loadDriver(\BotMan\Drivers\Facebook\FacebookDriver::class);
$botman = BotManFactory::create($config);
$botman->hears('hello', function (BotMan $bot) {
$bot->reply('Hello yourself.');
});
$botman->listen();任何想法都很感谢。
发布于 2019-02-04 23:07:30
已经被困了一段时间,直到我意外地找到了解决方案。问题出在PHP版本错误;因为BotMan需要>= 7.1,所以我从7.0更新到7.2,并确信我已经运行了它。我检查了终端php -v,结果显示是7.2,但是检查phpinfo()是否有其他问题,我注意到PHP版本是7.0
换句话说,在更新PHP时,您还需要为您的Apache服务器更新它,否则它将继续使用旧版本。
请查看以下链接,了解如何执行此操作。
https://askubuntu.com/questions/902637/how-can-i-upgrade-my-php-version
https://tecadmin.net/switch-between-multiple-php-version-on-ubuntu/
当上传聊天机器人到公共主机时,记得检查那里的PHP版本--在我记得检查我的主机PHP版本并相应地更新它之前,我花了一段时间对同样的错误感到沮丧。
https://stackoverflow.com/questions/54447613
复制相似问题