how to use webhook for checking users are livestreaming and get there data?how to create webhook url for twitch developers ?
the Webhook you is create by you
it is the URL that data is POSTed to on your server
So when you write the code to consume webhook data, you will decide what URL it will be.
Stream Online is foind her EventSub Subscription Types | Twitch Developers
That suggests your body type didn’t match the header type.
IE you sent a JSON body, but didn’t say you were sending JSON with a header.
I have added this in header for request
Thats not the correct header.
Thats also the header used with the kraken API which is long dead.
The normal JSON header is
Sure this might work not but it’s not standards
same error for this one also , how to solve this error ?
What does your code look like to make the request to create a subscription?
(post deleted by author)
You declared you were posting JSON
And then posted a form.
The form layout isn’t correct for POSTing as a form.
It’s easier to send as JSON. So
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($object));
Should do the trick rather than
(post deleted by author)
<?php $client = ''; $token = ''; $user_id= ''; $callback = ''; $secret = ''; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'https://api.twitch.tv/helix/eventsub/subscriptions'); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Content-Type: application/json', 'Client-ID: ' . $client, 'Authorization: Bearer ' . $token )); curl_setopt($ch, CURLOPT_POST, 1); $payload = array( 'type' => 'stream.online', 'version' => '1', 'condition' => array( 'broadcaster_user_id' => $user_id ), 'transport' => array( 'method' => 'webhook', 'callback' => $callback, 'secret' => $secret ) ); print_r($payload); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload)); curl_exec($ch);
Successfully created a subscription request for me
Earlier I copy/pasted your “broken header” but didn’t notice you put
Accept where it should be
Using the TwitchCLI the result is
$ twitch event verify-subscription cheer -F https://dev.clickitfame.com/twitch/webhook/callback ✗ Invalid response. Received <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <html><head> <title>401 Unauthorized</title> </head><body> <h1>Unauthorized</h1> <p>This server could not verify that you are authorized to access the document requested. Either you supplied the wrong credentials (e.g., bad password), or your browser doesn't understand how to supply the credentials required.</p> <p>Additionally, a 401 Unauthorized error was encountered while trying to use an ErrorDocument to handle the request.</p> </body></html> as body, expected 3aa60148-3314-44b5-27f7-3d644ebf6c9d ✗ Invalid content-type header. Received type text/html with charset iso-8859-1. Expecting text/plain. ✗ Invalid status code. Received 401, expected a 2XX status
Your server cannot be reached due to the basic authentication dialog
% twitch event verify-subscription cheer -F https://dev.clickitfame.com/twitch/webhook/callback | more ✗ Invalid response. Received <!doctype html> <html class="theme-light"> <!-- Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException: The POST method is not supported for this route. Supported methods: GET, HEAD. in file /home2/clickit9/public_html/oguzhan-clickitfame/vendor/laravel/framework/src/Illuminate/Routing/AbstractRouteCollection.php on line 117 SNIP as body, expected 6b4592bb-7dfe-480a-8561-6c76d14e3f8a ✗ Invalid content-type header. Received type text/html with charset UTF-8. Expecting text/plain. ✗ Invalid status code. Received 405, expected a 2XX status
Something isn’t grabbing and processing the POST request correctly.
You can download and use the CLI to test yourself - Twitch CLI | Twitch Developers
yes I have tried but unable to install
scoop in windows
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.