0
我有这样的脚本来检查歌名和streamName中(DJ)的听众,但它并不总是工作像它应该转换shoucast统计
它应该是,如果状态1展示一下统计抢别的节目下线。但它不想工作,我得到这个代码从一个朋友,他不希望重新编码,但我不知道如何使它与Shoutcast的2.0
继承人的代码工作
<?php
class radioStuff {
/**
Shoutcast specific class to grab server stats
*/
private $url = "http://sc.*REMOVED*.co.uk";
private $port = 80;
private $json_object;
public function __construct() {
$ch = curl_init();
// Disable SSL verification
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
// Will return the response, if false it print the response
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Set the url
curl_setopt($ch, CURLOPT_URL,$this->url . ':' . $this->port . '/stats?json=1');
// Execute
$result=curl_exec($ch);
// Closing
curl_close($ch);
$this->json_object = json_decode($result);
}
public function getHabboUrl() {
$imageString = 'http://www.habbo.com/habbo-imaging/avatarimage?user=' . $this->json_object->servergenre . '&direction=4&head_direction=3&action=wlk&gesture=sml';
return $imageString;
}
public function getCurrentListeners() {
return $this->json_object->currentlisteners;
}
public function getSTATUS() {
return $this->json_object->streamstatus;
}
public function getCurrentDJ() {
return $this->json_object->servertitle;
}
public function getCurrentSong() {
return $this->json_object->songtitle;
}
}
$radio = new radioStuff();
if($radio->getSTATUS == 1) {
$response = array(
'dj' => 'Radio statistics are offline!',
'song' => 'We are offline!', 'listeners' => ''
);
header('Content-Type: application/json');
echo json_encode($response);
} else {
$response = array(
'dj' => $radio->getCurrentDJ(),
'song' => $radio->getCurrentSong(),
'listeners' => $radio->getCurrentListeners()
);
header('Content-Type: application/json');
echo json_encode($response);
}
非常感谢。 – Skye
我需要多一点帮助,这个脚本 – Skye
这应该为Shoutcast的1.0工作,你可以得到它的Shoutcast的2.0 '公共职能radioInfo($网址)工作{ \t \t \t \t \t \t $选择采用=阵列( \t \t \t \t \t \t \t的 'http'=>数组( \t \t \t \t \t \t \t \t \t '方法'=> 'GET', \t \t \t \t \t '标题'=> '的User-Agent:Shoutcast一样松状态(Mozilla的兼容)\ r \ N' \t \t \t \t \t \t \t \t) \t \t \t \t \t \t); \t \t \t $ context = stream_context_create($ opts); \t \t \t $ data = @file_get_contents($ url,false,$ context); \t \t \t如果(的preg_match( “/流是目前最多的私人(未上市)/”,$数据)){ \t \t \t \t \t \t \t $返回[ '在线'] = TRUE; ' – Skye