Hi, I'm trying to use file_get_contents in php to display an RSS feed. However, when I try to load the page, it fails (as if waiting for something to complete). If I remove the code and save the file again, the page still refuses to work for 5 minutes or so, after which, it goes back to normal. Can anyone help shed any light on what is going on? I use the same code on another site and it works perfectly. Any advice appreciated. Thanks.
//Displays an xml feed on the page
function display_xml_feed($feed_url, $num_records, $before, $after) {
// Get data from feed file
if(!$response = file_get_contents($feed_url)) {
return '';
}
$xml = simplexml_load_string($response);
$count = 0;
// Browse structure
foreach($xml->channel->item as $one_item)
{
if($count < $num_records) {
$html .= $before.'<a href="'.htmlentities($one_item->link).'">'.
$one_item->title.'</a>'.$after;
$count++;
} else {
break;
}
}
return $html;
}