Hi 3ventic,
I put there the client ID. Still doesn’t work. How i can use curl ? I am not a programmer at all :(.
My code looks like this now:
<?php include("_mysql.php"); $mysqli = new mysqli($host, $user, $pwd, $db); $streams = $mysqli->query("SELECT * FROM ".PREFIX."streams"); while ($ds = $streams->fetch_assoc()) { $streamID = $ds['streamID']; $channel = $ds['channel']; $type = $ds['type']; switch($type) { case 1: // Twitch Stream API $twitch_api = 'https://api.twitch.tv/kraken/streams/'.$channel; // Input your Client-ID here. Obtained by registering the API through Twitch. $ClientId = ""; $ch = curl_init(); curl_setopt_array($ch, array(CURLOPT_HTTPHEADER => array('Client-ID: ' . $ClientId), CURLOPT_RETURNTRANSFER => true, CURLOPT_URL => $twitch_api)); $result = curl_exec($ch); curl_close($ch); $twitch_json = json_decode($result, true); if ($twitch_json && $twitch_json->stream) { $live = 1; $viewers = $twitch_json->stream->viewers; $thumb = $twitch_json->stream->preview->large; } else { $live = 0; } break; } $query = "UPDATE ".PREFIX."streams SET status='".$live."', viewers='".$viewers."', thumb='".$thumb."' WHERE streamID='".$streamID."'"; $result = $mysqli->query($query); } $mysqli->close(); ?>