YouTube Live Webhook 回调内容为空
YouTube Live Webhook Callback Content Empty
这是我用于 YT Live 的 pubsubhub 的回调端点,当我开始直播时它会收到来自 YouTube 的请求,但它的输出是空的。
server.post('/yt_webhook', async function(req,res){
console.log('in post');
console.log(req.read());
console.log(req.body);
console.log(req.query);
res.status(200);
res.send();
})
这个输出是
in post
null
{}
{}
当文档声明它应该是 YouTube 视频的 XML 格式时。搜索完整的请求对象,我没有看到任何指向它的东西。
使用 express-xml-bodyparser 作为中间件就可以了。现在我有:
var xmlbodyparser = require('express-xml-bodyparser');
server.use(xmlbodyparser())
server.post('/yt_webhook', async function(req,res){
console.log(req.body);
res.status(200);
res.send();
})
这是我用于 YT Live 的 pubsubhub 的回调端点,当我开始直播时它会收到来自 YouTube 的请求,但它的输出是空的。
server.post('/yt_webhook', async function(req,res){
console.log('in post');
console.log(req.read());
console.log(req.body);
console.log(req.query);
res.status(200);
res.send();
})
这个输出是
in post
null
{}
{}
当文档声明它应该是 YouTube 视频的 XML 格式时。搜索完整的请求对象,我没有看到任何指向它的东西。
使用 express-xml-bodyparser 作为中间件就可以了。现在我有:
var xmlbodyparser = require('express-xml-bodyparser');
server.use(xmlbodyparser())
server.post('/yt_webhook', async function(req,res){
console.log(req.body);
res.status(200);
res.send();
})