Script does not work anymore

Hello sry for my bad english.
I have a problem the Twitch scrip what I got 2 years ago is no longer and I do not really know how I integrate the new api might give me a tip. Thanks in advance

My File

<?php include("_mysql.php"); include("hitbox.php"); mysql_connect($host, $user, $pwd) or die ('FEHLER: Keine Verbindung zu MySQL'); mysql_select_db($db) or die ('FEHLER: Konnte nicht zur Datenbank "'.$db.'" verbinden'); ?> <?php $streamlist = ''; $clientID = "xxx"; function print_stream($status,$name,$logo,$viewer,$portal=1,$cat='') { if($viewer==0 and $status==0) $viewer = 'Offline'; else $viewer = $viewer.' Viewer'; if($cat != '') $cat = $cat.'
'; else $cat = ''; return('
  • '.$name.'
    '.$cat . $viewer.'
  • '); } $anz = 0; $abfrage = "SELECT * FROM ".PREFIX."streams ORDER BY `id`"; $ergebnis = mysql_query($abfrage); while($row = mysql_fetch_assoc($ergebnis)) { $name = $row['name']; if ($row['type'] == 1) { $data = json_decode(file_get_contents("".$name)); if($data->stream) { if($anz==0) { $featured = $name; $featured_player = 1; } $logo = $data->stream->channel->logo; $viewer = $data->stream->viewers; $cat = $data->stream->game; $streamlist .= print_stream(1,$name,$logo,$viewer,1,$cat); $anz++; unset($logo); } else { $offline[] = array($name,1); } } elseif ($row['type'] == 2) { $mediaName = strtolower($name); unset($Media); $Media = new Media; if ($media = $Media->getMedia('live',$mediaName)) { if($media['media_is_live'] == 1) { if($anz==0) { $featured = $name; $featured_player = 2; } $title = $media['media_status']; $onlineStatus = ($media['media_is_live'] == 1) ? 'online' : 'offline'; $screen = $media['media_thumbnail']; $viewer = $media['media_views']; $cat = $media['category_name']; $logo = $media['channel']['user_logo']; $streamlist .= print_stream(1,$name,$logo,$viewer,2,$cat); $anz++; unset($logo); } else { $offline[] = array($name,2); } } } } if(!empty($offline)) { foreach ($offline as $of) { $streamlist .= print_stream(0,$of[0],'../images/streamoff.jpg',0,$of[1]); } } if(isset($featured)) { echo ' '; } echo $streamlist; ?>

    Best regards.

    Your queries to the API need to include a client ID. Either in the header or in the URL.

    1 Like

    Thank you for your quick response. Only my problem is that I had to enter the Webinterface only the names and which were directly online. With the Id, I knew only how I put it into the script I do not know unfortunately since I control it by mysql here is a picture of the design :slight_smile:

    yeah, with v5 of the API, all channel names have to be converted over to channel ID (users now uses ID as well)… you can convert then using the /users?login= endpoint…

    so for instance, to get the channelId for aero2k13 you would make a call to /users?login=aero2k13 and it will return some json with the channel ID included…

    as for how to convert the version of the api you are currently using to v5, you’ll unfortunately have to just read the docs and make adjustments as necessary… you may still have a little bit of time if you were using v3… the time table is here.

    Hope this helps you out some

    This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.