Facebook Messenger API:设置 webhook 时遇到问题
Facebook Messenger API: Trouble setting up a webhook
我正在尝试在我的 PHP 网络服务器上为新的 Facebook Messenger 机器人平台设置网络挂钩,但收到此错误:
The URL couldn't be validated. Response does not match challenge,
expected value = '364011207', received='
资源
https://developers.facebook.com/docs/messenger-platform/quickstart
https://developers.facebook.com/docs/messenger-platform/webhook-reference#common_format
非常感谢任何帮助。
不确定这是否有帮助,但是 FB 发送的查询参数带有下划线而不是点,例如:
- hub_verify_token
- hub_mode
- hub_challenge
P.S。
抱歉,这适用于 PHP
我遇到了一个修复程序。我放弃了我的 js 尝试并使用以下代码创建了一个新的 php 文件:
<?php
$challenge = $_REQUEST['hub_challenge'];
$verify_token = $_REQUEST['hub_verify_token'];
if ($verify_token === 'my_token_code') {
echo $challenge;
}
我从该视频的前 10 分钟得到了这段代码:
https://www.facebook.com/marketingdevelopers/videos/883648801749520/
@shane
webhook: function(req, res) {
if (req.query['hub.verify_token'] === 'tokentoken') {
res.send(req.query['hub.challenge']);
} else {
res.send('Error, wrong validation token');
}
}
注意确定你在做什么。但这就是我所做的并且它正在工作。
我已经使用 ngrok 服务器进行了测试,因为我没有域名并且回调 URL 是 https://werwrwetwtw.ngrok.io/webhook
希望对您有所帮助!
该代码是 node.js 代码,应该在服务器上 运行 而不是 [=23= 中的 <script>
标记中].
下面是使用 node.js 设置 Messenger 机器人的简单步骤:
https://github.com/voronianski/simon-le-bottle
本质上,您需要确保您的主机支持 node.js 应用程序并且 运行 它本身也是如此。它在 HTML.
内不起作用
我刚刚通过在回调中添加“/webhook”解决了这个问题 URL...
如果您 运行 这是一个 Node.js
应用程序,并且您来自 The Facebook Quickstart Guide mentioned in the question, you'll have to point the webhook URL to [your-server-root]/webhook
. Notice this part of the tutorial:
// Adds support for GET requests to our webhook
app.get('/webhook', (req, res) => {
...
// Responds with the challenge token from the request
res.status(200).send(challenge);
});
我正在尝试在我的 PHP 网络服务器上为新的 Facebook Messenger 机器人平台设置网络挂钩,但收到此错误:
The URL couldn't be validated. Response does not match challenge, expected value = '364011207', received='
资源
https://developers.facebook.com/docs/messenger-platform/quickstart
https://developers.facebook.com/docs/messenger-platform/webhook-reference#common_format
非常感谢任何帮助。
不确定这是否有帮助,但是 FB 发送的查询参数带有下划线而不是点,例如:
- hub_verify_token
- hub_mode
- hub_challenge
P.S。
抱歉,这适用于 PHP
我遇到了一个修复程序。我放弃了我的 js 尝试并使用以下代码创建了一个新的 php 文件:
<?php
$challenge = $_REQUEST['hub_challenge'];
$verify_token = $_REQUEST['hub_verify_token'];
if ($verify_token === 'my_token_code') {
echo $challenge;
}
我从该视频的前 10 分钟得到了这段代码: https://www.facebook.com/marketingdevelopers/videos/883648801749520/
@shane
webhook: function(req, res) {
if (req.query['hub.verify_token'] === 'tokentoken') {
res.send(req.query['hub.challenge']);
} else {
res.send('Error, wrong validation token');
}
}
注意确定你在做什么。但这就是我所做的并且它正在工作。
我已经使用 ngrok 服务器进行了测试,因为我没有域名并且回调 URL 是 https://werwrwetwtw.ngrok.io/webhook
希望对您有所帮助!
该代码是 node.js 代码,应该在服务器上 运行 而不是 [=23= 中的 <script>
标记中].
下面是使用 node.js 设置 Messenger 机器人的简单步骤: https://github.com/voronianski/simon-le-bottle
本质上,您需要确保您的主机支持 node.js 应用程序并且 运行 它本身也是如此。它在 HTML.
内不起作用我刚刚通过在回调中添加“/webhook”解决了这个问题 URL...
如果您 运行 这是一个 Node.js
应用程序,并且您来自 The Facebook Quickstart Guide mentioned in the question, you'll have to point the webhook URL to [your-server-root]/webhook
. Notice this part of the tutorial:
// Adds support for GET requests to our webhook
app.get('/webhook', (req, res) => {
...
// Responds with the challenge token from the request
res.status(200).send(challenge);
});