Cotonti / Open Source PHP Content Management FrameworkContent Management Framework

Forums / Cotonti / Support / Plugin Stream => My nightmare

Twiebie
#39480 2014-04-26 20:54

I think you need to re-arrange your code a bit as you are now parsing all streams to the TPL regardless of if they are online or not.

Here's an example without the use of JS:

$sql = $db->query("SELECT * FROM cot_streams")->fetchAll();

if ($sql)
{
    foreach ($sql as $data)
    {
        $json   = file_get_contents('https://api.twitch.tv/kraken/streams/'.$data['streams_name']);
        $stream = json_decode($json);

        if ($stream->stream)
        {
            $t->assign(array(
                'STREAMS_ID'              => $data['id'],
                'STREAMS_USER_ID'         => $data['userid'],
                'STREAMS_USER_TWITCHNAME' => $data['teststream']
            ));
            $t->parse('MAIN.STREAM_ROW');
        }
    }
}