I created a website that shows all of the streamers on a particular ARK server. It functions, but it takes FOREVER to load, and I believe this is due to my poor coding choices. (http://arksurvivors.com/twitchrp)
At the moment I am pulling from the API, separately, for every single streamer:
$tashaxe_twitch = json_decode(curl_get_file_contents('https://api.twitch.tv/kraken/channels/tashaxe'), true);
$tashaxe_status = $tashaxe_twitch['status'];
$tashaxe_avatar = $tashaxe_twitch['logo'];
$tashaxe = json_decode(curl_get_file_contents('https://api.twitch.tv/kraken/streams/tashaxe'), true);
$tashaxe_viewers = $tashaxe['stream']['viewers'];
$tashaxe_online = false;
if ($tashaxe['stream'] !=NULL) {
$tashaxe_online = true;}
and outputting to
<li class="mix tashaxe zell selkie <?php if($tashaxe_online) { echo $tashaxe_status; } else { echo 'offline'; } ?> ">
<img src="<?php echo $tashaxe_avatar; ?>" alt="Image 1">
<p><b>Zell</b></p>
<p class="streamer"><a href="http://twitch.tv/tashaxe" target="_blank">Tashaxe</a</p>
</li>
It may be asking a lot, but is there any way to get the JSON to only have to run through once or twice? I feel like I’ve reeeeally taken the long way around on this one, and I apologize if this is a lot to ask. I just figured this would be a good place to start so that I may improve on such projects in the future.