简体   繁体   English

Facebook Messenger API Webhook麻烦

[英]Facebook Messenger API webhook trouble

I am trying to setup a webhook for the Facebook Messenger Bot Platform and i am receiving this error: 我正在尝试为Facebook Messenger Bot平台设置一个Webhook,并且收到此错误:

The URL couldn't be validated. Response does not match challenge, expected value = '892694233', received='892694233<link rel...'

I am using a heroku host for testing and a callback URL with SSL, the project is on Laravel 5.2 and this is the code that processs the webhook setup 我正在使用heroku主机进行测试和带有SSL的回调URL,该项目位于Laravel 5.2上,这是处理webhook设置的代码

if ($request->get('hub_verify_token') == config('services.bot.verification_token')) {
        return (new Response())->setContent($request->get('hub_challenge'));
    }

return (new Response())->setContent('Error: token mismatch');

很抱歉收到我的帖子的最新答案,问题是我的Laravel应用程序中的APP_DEBUG(在.env文件中)设置为TRUE,并且请求从调试栏中获取了代码

I'm not familiarized with Lavarel, but looks like the way you are extracting the value of the parameter hub.challenge is giving you a wrong value: '892694233 我对Lavarel并不熟悉,但是看起来就像您提取参数hub的方式一样。挑战为您提供了错误的值:'892694233

If you return just the number in the response ('892694233') it should work. 如果您仅返回响应中的数字('892694233'),则该数字应该有效。 Maybe you can clean up the result of calling $request->get('hub_challenge') in order to remove the text at the end? 也许您可以清理调用$ request-> get('hub_challenge')的结果以删除最后的文本?

You have to do like this 你必须这样

    if (Request::input('hub_verify_token') === $hubVerifyToken) {
  echo Request::input('hub_challenge');
  exit;
}

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

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