Twitch API to Show List of Streamers

So what I’m trying to do here is create a page to display a list of specific users and use the api to pull information to create links and point it to an embedded iframe.


The channels

$channels = array('everadiolive', 'djyumene', 'mrblades', "themittanidotcom", "daopa") ;

The part that does stuff

$callAPI = implode(",",$channels);
$dataArray = json_decode(file_get_contents('' . $callAPI, false), true);

foreach($dataArray['streams'] as $mydata){

    if($mydata['streams'] == null or $mydata['streams'] == ""){
        $name      = $mydata['channel']['display_name'];    

        echo "<a href='" .$name. "/embed' target='tbox'><img src='" .$name. ".png'></a>";


This works, however there’s some issues that I’m having. It’s only showing the streams that are online (I want it to show all that are specified on the first line).

I also am seeing an issue to get more than 3 streams to show up. In this I have 4 streams listed, and the 4th one was active (at the time of this post) however it was ignored, where the 3rd stream that was running did show.

The first two were both offline, where it should have shown an offline graphic, there was nothing, so it’s not displaying unless the stream is offline.

I thought that I had this correct but seems I’m missing something here. So I’m hoping someone can help me here.


Source: json

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.