cotonti.com : Plugin Stream => My nightmare https://www.cotonti.com Последние сообщения в теме Cotonti en Thu, 09 Oct 2025 02:29:39 -0000 Twiebie You're welcome!

]]>
сб, 26 апр 2014 22:00:29 -0000
Harker I modified my code with your and now it works marvelously !!

One very very thank you for your help :)

]]>
сб, 26 апр 2014 21:16:51 -0000
Twiebie 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');
        }
    }
}

 

]]>
сб, 26 апр 2014 20:54:36 -0000
Harker Hello to all,

I created a plugin which allows me to see the status of the streams of my members. It works very well but I do not manage to have that I want in spite of my nights white and my liters of coffee.

At present, my page shows all the on-line and off-line streams. I would need your help so that my plugin shows only the on-line streams.

 

PHP

$sql = $db->query("SELECT * FROM cot_streams");
while ($data = $sql->fetch())
	{
	$data['teststream'] = '<a class="ltwitch" href="https://www.cotonti.com/#" data-tnick="'.$data['streams_name'].'">'.$data['streams_name'].'</a> (<span>...</span>)';
	$t-> assign(array(
	'STREAMS_ID' => $data['id'],
	'STREAMS_USER_ID' => $data['userid'],
	'STREAMS_USER_TWITCHNAME' => $data['teststream']
		
	));

	$t->parse('MAIN.STREAM_ROW');
}

TPL

<!-- BEGIN: STREAM_ROW -->
	<div>{STREAMS_ID}</div>
	<div>{STREAMS_USER_ID}</div>
	<div>{STREAMS_USER_TWITCHNAME}</div>
<!-- END: STREAM_ROW -->

JS

jQuery(document).ready(function ($) {
    $('.ltwitch').each(function () {
        var tnick = $(this).data('tnick');
        var span = $(this).next();
        $.getJSON("https://api.twitch.tv/kraken/streams/" + tnick + ".json?callback=?", function (c) {
            if (c.stream == null) {
                span.html("Offline");
            } else {
                span.html("Online");
            }
        });
    });
});

 

PLLLLeeeeeaaassseeee Help me to transform my nightmares, I do not sleep any more ^^

]]>
сб, 26 апр 2014 14:58:50 -0000