我真的很困惑如何讓我的facebook儀表板中的信使設置。我已經設定了在Heroku使Node.js應用程序與Facebook的API進行交流,並試圖連接到以下回調URL:如何將heroku回調URL添加到Facebook儀表板?
https://ancient-dawn-XXXXX.herokuapp.com/webhook/
但是我收到以下錯誤:
The URL couldn't be validated. Callback verification failed with the following errors: HTTP Status Code = 403; HTTP Message = Forbidden
我的應用程序的app.js文件包含以下代碼:
var express = require("express");
var request = require("request");
var bodyParser = require("body-parser");
var app = express();
app.use(bodyParser.urlencoded({extended: false}));
app.use(bodyParser.json());
app.listen((process.env.PORT || 5000));
// Server index page
app.get("/", function (req, res) {
res.send("Deployed!");
});
// Facebook Webhook
// Used for verification
app.get("/webhook/", function (req, res) {
if (req.query["hub.verify_token"] === "process.env.VERIFICATION_TOKEN") {
console.log("Verified webhook");
res.status(200).send(req.query["hub.challenge"]);
} else {
console.error("Verification failed. The tokens do not match.");
res.sendStatus(403);
}
});
當我嘗試訪問網址https://murmuring-temple-XXXXX.herokuapp.com/webhook/
我還收到FORBIDDEN回覆。
缺什麼?
您的應用正在工作嗎?當你進入根目錄時,你會看到「已部署!」信息。 –