# Script does not work anymore

**URL:** <https://discuss.dev.twitch.com/t/script-does-not-work-anymore/9271>\
**Category:** API\
**Created:** [February 15, 2017, 4:32pm UTC](https://discuss.dev.twitch.com/t/script-does-not-work-anymore/9271 "2017-02-15T16:32:10Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Reno](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/reno/32/2491_2.png) [@Reno](https://discuss.dev.twitch.com/u/Reno)\
**Post date:** [February 15, 2017, 4:32pm UTC](https://discuss.dev.twitch.com/t/script-does-not-work-anymore/9271/1 "2017-02-15T16:32:10Z")

</div>

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("https://api.twitch.tv/kraken/streams/".$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.  
Reno

---

<div class="post-metadata">

**Author:** ![matt\_thomas](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/matt_thomas/32/710_2.png) [@matt\_thomas](https://discuss.dev.twitch.com/u/matt_thomas)\
**Post date:** [February 15, 2017, 4:44pm UTC](https://discuss.dev.twitch.com/t/script-does-not-work-anymore/9271/2 "2017-02-15T16:44:42Z")

</div>

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

> **[Client-ID required for Kraken API calls – Twitch Blog](https://blog.twitch.tv/client-id-required-for-kraken-api-calls-afbb8e95f843?gi=5d5ee8ebecd6)**
>
> TL;DR: On Monday, August 8th, 2016, we’re going to really-for-real require the Client-ID header on all of your API requests to Kraken.

---

<div class="post-metadata">

**Author:** ![Reno](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/reno/32/2491_2.png) [@Reno](https://discuss.dev.twitch.com/u/Reno)\
**Post date:** [February 15, 2017, 5:33pm UTC](https://discuss.dev.twitch.com/t/script-does-not-work-anymore/9271/3 "2017-02-15T17:33:21Z")

</div>

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  
[https://img4.picload.org/image/ropwlidl/twi.png](https://img4.picload.org/image/ropwlidl/twi.png)🙂

---

<div class="post-metadata">

**Author:** ![Ague](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/ague/32/2428_2.png) [@Ague](https://discuss.dev.twitch.com/u/Ague)\
**Post date:** [February 16, 2017, 6:43am UTC](https://discuss.dev.twitch.com/t/script-does-not-work-anymore/9271/4 "2017-02-16T06:43:11Z")

</div>

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](https://dev.twitch.tv/docs/).

Hope this helps you out some

---

<div class="post-metadata">

**Author:** ![system](https://d2opxh93rbxzdn.cloudfront.net/original/2X/0/05909729875cce3b53e59d5561c4d23bb14948fc.png) [@system](https://discuss.dev.twitch.com/u/system)\
**Post date:** [March 18, 2017, 6:43am UTC](https://discuss.dev.twitch.com/t/script-does-not-work-anymore/9271/5 "2017-03-18T06:43:14Z")

</div>

Closed on March 18, 2017, 6:43am UTC

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