【发布时间】:2018-08-07 12:29:34
【问题描述】:
我正在测试 facebook messenger webhook, 注册我已经设置了必要的参数 这是我的 php 代码,
代码:
$postData = request()->all();
// Your verify token. Should be a random string.
$verfityTocken = "fR8Eu5Wj9m9WTLvA0vIZYMenoTvu51bdGaL70FFb9pHhSeySbLHa0Q5cTLaJ";
// Parse the query params
$mode = $postData['hub_mode'];
$token = $postData['hub_verify_token'];
$challenge = $postData['hub_challenge'];
// Checks if a token and mode is in the query string of the request
if ($mode && $token) {
// Checks the mode and token sent is correct
if ($mode === 'subscribe' && $token === $verfityTocken) {
// Responds with the challenge token from the request
//echo 'WEBHOOK_VERIFIED';
return response(request()->input("hub_challenge"), 200);
} else {
// Responds with '403 Forbidden' if verify tokens do not match
return response('403 Forbidden', 403);
}
}
现在在从 messanger 面板验证 webhook 时出现错误,如图所示
我不明白为什么收到尾随数据\u0033Clink。
【问题讨论】:
-
\u0033是一个编码的<,所以这看起来你的系统除了挑战之外只输出 HTML 代码 -<link …>但是你没有给我们任何信息,无论你是什么库/框架在那里使用,所以很难说到底是什么原因造成的。甚至不清楚上面的代码在什么上下文中 - 看到return被使用,它可能是更广泛的路由系统中的一个函数/方法(?)......无论如何,检查文档以了解你在那里使用的任何内容,你必须做些什么来防止它在之后给出“正常输出”。 -
我在 php laravel 5.6 框架中调用这个请求
-
@CBroe 感谢您的帮助,我已添加标题作为响应,它现在正在工作
-
@Priyank 你能回答一下你是怎么做到的吗
标签: facebook get httprequest facebook-messenger-bot