Youtube PubSubHubbub 在我的回调中没有收到帖子请求

问题描述

我正在尝试在 nodejs 中集成 youtube 通知系统。我有我的端点工作,使用邮递员我可以接收数据。

router.get("/youtube/callback",(req,res) => {
    console.log('here',req.body,req.query,req.params,req.headers)
    let query = req.query
    if('hub.challenge' in query){
        let channelID = query['hub.topic'].split('=').pop()
        /*if(!bot.youtube.pendingVerify.has(channelID)) {
            console.log('Invalid youtube hook sent to me',channelID,req.headers)
            return res.sendStatus(401)
        }*/
        bot.youtube.lease.set(channelID,Date.Now() + (query['hub.lease_seconds'] * 1000))
        bot.youtube.pendingVerify.delete(channelID)
        return res.status(202).send(query['hub.challenge'])
    }
})

router.post('/youtube/callback',res) => {
    console.log('here post',req.headers)

    let hmac = generateHMAC(req.query['hub.challenge'],'very_secret',"sha1")
})

function generateHMAC(hmac,secret,algo = 'sha256'){
    return `${algo}=${crypto.createHmac(algo,secret).update(hmac).digest('hex')}`
}

我什至可以使用 https://pubsubhubbub.appspot.com?hub.callback=http://ec5505102119.ngrok.io/api/webhooks/youtube/callback&hub.mode=subscribe&hub.topic=https://www.youtube.com/xml/Feeds/videos.xml?channel_id=UC7MIeWKsLh9g-06cl3396yw

订阅订阅

如您所见,我正在使用 ngrok 进行测试,并且可以验证子请求。它使获取 /youtube/callback 的请求很好,我用 202 响应以确认子,但是当我想使用它进行测试时

https://pubsubhubbub.appspot.com/publish

我在其中输入 topicURL = https://www.youtube.com/xml/feeds/videos.xml?channel_id=UC7MIeWKsLh9g-06cl3396yw

点击发布按钮,然后在我检查相同的主题 url 下,我可以清楚地看到它发送了提要,但我在我的帖子端点

enter image description here

上没有收到任何提要 也看不到这里

enter image description here

请任何人告诉我我做错了什么。过去 2 天我一直在努力弄清楚,因为没有不和谐的服务器,所以我不得不在这里问。

编辑:我正在关注 RFC 文档 https://pubsubhubbub.github.io/PubSubHubbub/pubsubhubbub-core-0.4.html#RFC2616

的 0.4 版本

先谢谢你!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)