Youtube PubSubHubBub Integration
Asked Answered
C

2

7

Been stuck on this integration problem for hours now. I am trying to subscribe to a youtube channel updates using https://pubsubhubbub.appspot.com/subscribe.

Subscription Request

And my server is setup to respond with:

Server Response

But when I press DO IT, I always get back the error saying Challenge mismatch.

I am unsure which parameter I am missing to set.

Chute answered 22/8, 2018 at 12:13 Comment(0)
C
10

The intended response is not a static value as hub_challenge. It should return back the hub.challenge value which is received in query parameters when GET request is sent to the callback url.

More Information

The request will be something like /notifications?hub.topic=https://www.youtube.com/xml/feeds/videos.xml%3Fchannel_id%3DUCn0QU5ZOaVnEf7LkdyPF9kQ&hub.challenge=216582865281647747&hub.mode=subscribe&hub.lease_seconds=432000"

The response of should be the value hub.challenge (216582865281647747)

Chute answered 22/8, 2018 at 12:13 Comment(1)
If anyone is doing this with PHP, remember that hub.challenge has to be accessed as hub_challenge source: https://mcmap.net/q/18658/-how-to-stop-php-replacing-dot-characters-in-get-post-or-cookie-namesGullett
M
1

Assuming you're using (either directly or indirectly) https://www.npmjs.com/package/body-parser, you could do something like this:

const responseText = request.query['hub.challenge'] || "no challenge" response.send(responseText)

But even if not that exact syntax, figure out how to log the query parameters that the hub adds when hitting the callback URL. There you will see the value for 'hub.challenge' which you can then send back in the response.

Metamorphose answered 18/9, 2019 at 12:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.