Hello,
I would like to use the webhook for to show if a user is live.
I executed this code (replaced own data):
$data = array(
‘hub.callback’ => ‘https://myurl/twitch/webhook_redirect.php’,
‘hub.mode’ => ‘subscribe’,
‘hub.topic’ => ‘https://api.twitch.tv/helix/streams?user_id=147837668’,
‘hub.lease_seconds’ => 864000
);
$dataString = json_encode($data);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"https://api.twitch.tv/helix/webhooks/hub");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $dataString);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Client-ID: myclientid',
'Content-Type: application/json',
'Content-Length: ' . strlen($dataString)
));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$server_output = curl_exec ($ch);
$info = curl_getinfo($ch);
curl_close ($ch);
print_r($server_output);
print_r($info);
I got the response code 202 and my webhook_redirect.php was requested and I got the hub_challenge “C5JUIAPXHt2OogUeP8oXv8uXhoZ_BCq5vj9XUPaN”.
But if I go live with the user, my script got no request of twitch. This is my webhook_redirect.php:
<?php
file_put_contents(“get.txt”, json_encode($_GET)."\n", FILE_APPEND);
file_put_contents(“post.txt”, json_encode($_POST)."\n", FILE_APPEND);
file_put_contents(“request.txt”, json_encode($_REQUEST)."\n", FILE_APPEND);
$request_body = file_get_contents(‘php://input’);
file_put_contents(“json.txt”, $request_body."\n", FILE_APPEND);
In the files are no new entries for requests from twitch.
How can I fix this or is it a twitch bug?
kind regards
Hanashi