|Getting list of online streams- very slow?||dysruption||6/27/12 1:56 PM|
As of right now I am using this code:
$chan = "http://api.justin.tv/api/stream/list.json?channel=" . $channel;
$json = file_get_contents($chan);
$exist = strpos($json, 'name');
But for multiple streams, like 20, on one page. So it cycles through them, checking each one. However, this causes the page to load INCREDIBLY slowly. Is there a faster way of doing this? Thank you!
|Re: Getting list of online streams- very slow?||David Offerman||6/29/12 6:04 PM|
PHP has a json_decode, then you can do a foreach() statement with that array. Also I suggest not having that request in your page load. Make a cron job to run on your server every minute or so, and cache the results. This will make it load much faster.
|Re: Getting list of online streams- very slow?||David Offerman||6/29/12 6:05 PM|
Also (forgot to include), you can add multiple streams to one request by adding commas in between them. Such as
http://api.justin.tv/api/stream/list.json?channel=USER1,USER2,USER3 etc etc