1

I got a script which is looking up if a user is either ONLINE or OFFLINE. I stated 2 behaviors for now, PRINTF('Online') and PRINTF('OFFLINE') just to see everything works as it should.

Now to my question,

I would like to have if user is OFFLINE, it should embed his youtube channel instead of just printing OFFLINE. How can I code this?

<?php
$channel = "CHANNEL-NAME";

$json_file = @file_get_contents("http://api.justin.tv/api/stream/list.json?".
                                "channel={$channel}", 0, null, null);
$json_array = json_decode($json_file, true);

if( array_key_exists( '0',       $json_array )
 && array_key_exists( 'channel', $json_array[0] )
 && $json_array[0]['name'] == "live_user_{$channel}" )
{
    $channelTitle = $json_array[0]['channel']['title'];
    $title        = $json_array[0]['channel']['status'];

    printf('Online'); 
}
else
{
    printf('Offline');
}

?>
pleasedontbelong
  • 19,542
  • 12
  • 53
  • 77
  • Embed what part of the youtube channel? You can forward him to the youtube channel if you want. Or embed a youtube video/whole page. Be a little bit more specific. – Tuim Jan 28 '13 at 14:25

0 Answers0