Skip to content

Instantly share code, notes, and snippets.

@navarr
Created August 15, 2013 00:58
Show Gist options
  • Save navarr/6237336 to your computer and use it in GitHub Desktop.
Save navarr/6237336 to your computer and use it in GitHub Desktop.
<?php
// This is a small PHP snippet to fetch the amount of viewers for a channel.
$data = @json_decode(file_get_contents('https://api.twitch.tv/kraken/streams/8_bit_hero'), true);
$viewerCount = 0;
if ($data && !is_null($data['stream'])) {
$viewerCount = $data['stream']['viewers'];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment