Change script to Curl


#1

Hi.

I have a script that needs to be changed from “file_get_contents” to CURL.

Can anyone help me with this? I’m a noob in PHP so any help would be appreciated.

My script;

$stream_url = “http://streams.greenhost.nl:8080/amateurmuziek”;
$xspf_url = $stream_url . “.xspf”;
$xml = file_get_contents($xspf_url);
if($xml){
$data = simplexml_load_string($xml);
// Track artist
print $data->trackList->track->creator;
// Track title
print $data->trackList->track->title;
}


#2

http://php.net/manual/en/curl.examples-basic.php


#3

Well that isn’t helpful at all…

i think it is something like this…

function getXSPF(){ $XSPFurl = ‘http://xxx.xxx.xxx.xxx:8000/mount.xspf'; $xml = simplexml_load_file($XSPFurl); $stream[‘info’][‘title’] = (string) $xml->trackList->track->title; $stream[‘info’][‘location’] = (string) $xml->trackList->track->location;
preg_match_all('/^(.*):(.*)/m', (string) $xml->trackList->track->annotation,$matches);
if(isset($matches[1]) && isset($matches[2])){
    $t = array_combine($matches[1], $matches[2]);
    foreach($t as $key => $val){
        $fkey = str_replace(" ", "_",$key);
        $stream['info'][strtolower($fkey)] = trim($val);
    }
}
return $stream;

}

But this aint working


#4

Do you want cURL or not? That is how you make a cURL request, which is what you stated you were after.