I’m using a script to display twitch streams on my website and everything works great except for one aspect… Instead of fetching the most popular stream on twitch I want it to fetch the most popular stream within a game category.
(Thanks to matt_thomas for the script BTW)
ORIGINAL:
/* None of the $channels I wanted are avaiable now, so fetch the most popular one */
$backupArray = json_decode(@file_get_contents(‘https://api.twitch.tv/kraken/streams?limit=1’ . $callAPI), true);
if ( $backupArray != null ) {
foreach($backupArray[‘streams’] as $mydata){
if($mydata[’_id’] != null) {
$name = $mydata[‘channel’][‘display_name’];
$viewers = $mydata[‘viewers’];
EDITED:
/* None of the $channels I wanted are avaiable now, so fetch the most popular one */
$backupArray = json_decode(@file_get_contents(‘https://api.twitch.tv/kraken/streams?game=CS:GO’ . $callAPI), true);
if ( $backupArray != null ) {
foreach($backupArray[‘streams’] as $mydata){
if($mydata[’_id’] != null) {
$name = $mydata[‘channel’][‘display_name’];
$viewers = $mydata[‘viewers’];
I have little to no knowledge on what I’m doing so I’m sure it’s a simple fix… Thanks for anyone’s help in advance