Hello there, dear community and fellow developers,
I’m implementing Web Hooks to get notifications when streamers go online/offline.
So far I’ve managed to send subscription request, get 202, and get confirmation GET request to callback handler with correct params:
[hub_challenge] => X4v8lzz1nE0TuW7fruXRLaJ7wOYih37yyxUrd8xd
[hub_lease_seconds] => 864000
[hub_mode] => subscribe
[hub_topic] => https://api.twitch.tv/helix/streams?user_id=194344384
I reply to it with
(no quotes or whitespace before or after), HTTP status 200
I believed that would get me subscribed.
Was I wrong, apparently, as when I put stream online/offline (using OBS streaming software), I receive no more requests to callback handler.
I use php and the code like below to see what’s up:
$file = fopen('/path/to/writeable/file/twitch-tmp.txt', 'a');
echo 'hook listener; get/post: : '.PHP_EOL;
echo 'php input'. PHP_EOL;
$x = ob_get_clean();
And the file does not get anything added to it.
Any ideas why could that be or what should I try?
Thanks a lot in advance!
P.S. Maybe there is a way to check with webhooks if I subscribed OK?
It would help with debugging such things.
When you test, are you staying online for some time, or just going online then immediately offline? Webhooks have several minutes delay to give time for all the API servers time to update so that any webhook notification will be consistent with the API. This also means that a stream going online then offline shortly after, or a stream that is already online having a brief outage, wont send notifications.
Without seeing your code, another point that sometimes causes people trouble is not realising the notification is a POST request, so make sure your handler is capable of dealing with that type of request rather than just a GET.
Thank you very much for the reply.
I just edited my question to include the code I use to see what’s up (on the handler).
As for the stream, I tried streaming for about 5-10 minutes to no avail.
Just now started again, will let it run for 30-60 minutes to allow all updates… I’ll post if it helps in 30-60 minutes :).
I’m not a PHP guy so can’t really offer much help with your code. You’re at least getting the challenge verification so you know your GET handler is working, have you tried POST’ing to your own callback URL yourself just so you can check that it is getting the POST requests correctly?
Heck, were you right!
Yii was expecting csrf form check with post, how could I forget.
Thanks a bunch!)
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.