Я пытаюсь получить доступ к удаленным данным с помощью Curl или file_get_contents, но они оба возвращают 404 Не найдено. Одна и та же ссылка в браузере и на другом сервере работает. Может быть, что-то отключено в конфиге php?
Вот та же функция с Curl и получением файла:
public function getNowPlaying() {
$source = "http://v12.radionsm.lv/lv/stats";//$this->url . "/lv/stats";
$ch = curl_init($source);
curl_setopt($ch, CURLOPT_USERAGENT, $this->useragent);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, 0);
if (curl_exec($ch) === FALSE) {
die("Curl error: " . curl_error($ch));
}
$data = curl_exec($ch);
curl_close($ch);
$xml = simplexml_load_string($data);
$data = array(
'status' => (string) $xml->status,
'onAir' => (string) $xml->dj_name,
'artist' => (string) $xml->artist_name,
'title' => (string) $xml->song_name,
'albumArt' => (string) $this->medium($xml->song_pic)
);
return $data;
}
public function getNowPlaying() {
$source = "http://v12.radionsm.lv/lv/stats";
echo file_get_contents($source);
}
Спасибо.