Answer the question
In order to leave comments, you need to log in
Why does the script not work on the hosting, but works on the local?
In short, I have a website and it has a player with an online radio station stream. I wanted to add data about the playing track on the air to the player and for this I went to the hosting site for broadcasting on IceCast 2 (radioheart.ru). There was a script on their site to get data about the playing track, which I took. Having written the code on the local, everything worked perfectly (there were no errors) and the playing track was shown, but when the script was transferred to the hosting (I use hoster.kz), the script stopped working.
Script with the technique of adding to the site:
Create a radiostat.php file, add the following code to it and save it in the root of the site:
<?php
//НАСТРОЙКИ СКРИПТА//
//Ссылка на картинку, которая будет отображаться, если изображение не найдено в базе LAST.FM
$no_photo_url='http://upload.wikimedia.org/wikipedia/commons/3/37/No_person.jpg';
$width='100'; //ширина картинки
$height='100'; //высота картинки
//НЕ ИЗМЕНЯЙТЕ НИЧЕГО НИЖЕ///
//LIVE STREAM
$data = json_decode(file_get_contents("http://s0.radioheart.ru:8000/json.xsl?mount=/radioart"));
if (!count($data->mounts) || strlen($data->mounts[0]->server_name) < 2) {
//NONSTOP
$data = json_decode(file_get_contents("http://s0.radioheart.ru:8000/json.xsl?mount=/nonstop"));
}
$stream_title = $data->mounts[0]->server_name;
//Если сайт в кодировке windows-1251 (cp-1251), раскомментируйте следующую строчку
//$stream_title = iconv("UTF-8", "WINDOWS-1251", $stream_title);
$stream_description = $data->mounts[0]->description;
$listeners = $data->mounts[0]->listeners;
$song = $data->mounts[0]->title;
$image = '';
//Если сайт в кодировке windows-1251 (cp-1251), раскомментируйте следующую строчку
//$song = iconv("UTF-8", "WINDOWS-1251", $song);
$artist = explode(" - ", $song);
$artist = $artist[0];
$artist = str_replace(" ", " ", $artist);
$size = "large";
// Выводим данные
echo "<div id='radiostat'>";
echo "Название потока: $stream_title<br />";
echo "Описание потока: $stream_description<br />";
echo "Слушателей: $listeners<br />";
echo "Сейчас в эфире: $song<br />";
echo "</div>";
?>
<div id="radiostat">Загрузка...</div>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script>
function nowplay()
{
$.ajax({
url: "/radiostat.php", //Тут указываем файл со скриптами
cache: false,
success: function(html){
$("#radiostat").html(html); //Контейнер для вывода информации
}
});
}
$(document).ready(function(){
nowplay();
setInterval('nowplay()',30000); //Время в милесекундах, 30000=30сек
});
</script>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question