I wanted to try this feature with a simple code, I even get the 202 response after subscription but dont get a post request when i start streaming.
Am i doing something wrong with my test code? I tested with Google Script:
Thank you for advanced!
I wanted to try this feature with a simple code, I even get the 202 response after subscription but dont get a post request when i start streaming.
Am i doing something wrong with my test code? I tested with Google Script:
Thank you for advanced!
You don’t seem to be handling the challenge POST at all. See example flow.
Here’s how I handle the POSTs in my small php script (notice the hub.challenge
part):
<?php
ob_start();
header('Content-Type: text/plain');
if ($_REQUEST['hub.challenge']) {
die($_REQUEST['hub.challenge']);
}
if ($_SERVER['REQUEST_METHOD'] !== 'POST') die('not post');
$reqbody = file_get_contents('php://input');
header('Connection: close');
header('Content-Length: '.ob_get_length());
ob_end_flush();
ob_flush();
fastcgi_finish_request();
$json = [
'content' => "```\npostdata: $reqbody\n```"
];
$c = curl_init();
curl_setopt($c, CURLOPT_URL, "https://canary.discordapp.com/api/webhooks/-snip-");
curl_setopt($c, CURLOPT_POST, 1);
curl_setopt($c, CURLOPT_POSTFIELDS, json_encode($json));
curl_setopt($c, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
curl_exec($c);
curl_close($c);
Thank you for you’re fast reply. Is there available a documentation how to use hub.challenge?
Unfortunatelly i don’t understand this little script, how to handle or use the hub.challenge part.
You just need to print it out to confirm it, when it’s present in the request.
So i have to make something like this?
I printed it to the output the hub.challenge code. And i have to do more things? Becouse the webhook still don’t working.
Ok i figured out with Google Script inpossible making work the webhook. It is super sad me. Google Script gives 302 response code when i just print the challenge key when print as an html output full of other code which is not valid for the twitch webhook service.
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.