List of active streams using PHP & Twitch API

Ok so you have a number of issues

  1. file_get_contents - you should be using curl
  2. Your URL construction is wrong
  3. You are requesting Helix, but using the Kraken Data pattern to parse the result

Finally, the streams API will let you look up 100 streams at once, and it’ll only return those that are live. You can take the response and compared that with your Names array if you want to show a offline message.

You can call:

$url = ‘’ . implode(‘&user_login=’, $names);


$resullt = json_decode(theresponse);

foreach ($result->data as $stream) {
    echo '<iframe src="' . strtolower($stream->user_name) . '" frameborder="0" allowfullscreen="true" scrolling="no" height="378" width="620"></iframe>';

You may need to be aware of this issue:

Which may catch you out on some streams, and you probably want to convert to user_id’s so you don’t have to update your names array if/when someone changes their Twitch username

Finally, finally, as per

You will need to update your code to use an oAuth token, which in this case will probably work best with an App Access Token (aka Server to Server)