コード例 #1
0
<?php

include 'shoutcast.php';
$s = new Shoutcast('10.211.55.3', '8000');
if (!$s->server_online()) {
    echo 'Server offline';
} else {
    if (0 == $s->get('STATION_STATUS')) {
        echo 'Transmition off';
    } else {
        $format = '<strong>%s:</strong> %s <br />';
        //Print Current Listeners
        printf($format, 'Current Listeners', $s->get('CURRENT_LISTENERS'));
        //Print Current Song
        printf($format, 'Current Song', $s->get('CURRENT_SONG'));
        //Print Song History
        if ($s->admin_mode()) {
            $str_history = '';
            foreach ($s->get('SONG_HISTORY') as $song) {
                $str_history .= '<br />' . $song['TITLE'];
            }
            printf($format, 'Song History', $str_history);
        }
    }
}
コード例 #2
0
 * The port default is 8000
 * The stream is default to 1, this will not affect shoutcast v.1 usage.
 * 
 * Requirements
 * 
 * cURL
 * PHP 5.3.3+ 
 * 
*/
require_once 'Shoutcast.php';
// No password and default stream id (1)
$sc = new Shoutcast('example.com', 7309);
//Load the basic stats
if ($sc->getBasicStats()) {
    // can use the __get magic method
    echo $sc->songTitle;
    // can use the get method (the __get method just calls this one anyway)
    echo $sc->get('songtitle');
    // whatever you pass to the two above methods will be put through strtoupper()
    // as all of the keys are uppercase
    // get the XML out of the object so you can do whatever you want with it
    $xml = $sc->getXML();
    // you can then get the stats for a second server by setting the details again
    if ($sc->setDetails('anotherHost.com', 1234)->getBasicStats()) {
        echo $sc->songTitle;
    } else {
        echo $sc->getError();
    }
} else {
    echo $sc->getError();
}