forked from Wavestreaming/SHOUTcast-PHP-Class
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
50 lines (40 loc) · 1.26 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
/**
* Shoutcast Class Demo Usage
*
* Setting details:
* You can set the shoutcast details in the constructor or the setDetails() method.
* The constructor will call the setDetails method with the arguments that it receives.
*
* setDetails($host, $port = 8000, $pass = '', $stream = 1)
* 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();
}