Estoy tratando de encontrar un snippet de código php que me permita leer un rss procedente de un blog para incluirlo en una página web.
De momento he encontrado esto que más o menos funcione:
Código PHP:
function RSSreader($url="http://feeds.feedburner.com/fDisk")
{
//http://ca.php.net/manual/en/function.preg-match.php#61639
$rssstring = @file_get_contents($url);
/*
if ( $handle = @fopen($url, "r")) {
$content = "";
while(!feof($handle)){
$content .= fread($handle , 4096);
}
fclose($handle);
}
$rssstring = $content;
*/
preg_match_all("#<title>(.*?)</title>#s",$rssstring,$titel);
preg_match_all("#<item>(.*?)</item>#s",$rssstring,$items);
$n=count($items[0]);
for($i=0;$i<$n;$i++)
{
$rsstemp= $items[0][$i];
preg_match_all("#<title>(.*?)</title>#s",$rsstemp,$titles);
$title[$i]= $titles[1][0];
preg_match_all("#<pubDate>(.*?)</pubDate>#s",$rsstemp,$dates);
$date[$i]= $dates[1][0];
preg_match_all("#<link>(.*?)</link>#s",$rsstemp,$links);
$link[$i]= $links[1][0];
}
echo "<h2>".$titel[1][0]."</h2>";
for($i=0;$i<$n;$i++)
{
$timestamp=strtotime($date[$i]);
$datum=date('d-m-Y Hhi', $timestamp);
if(!empty($title[$i])) echo $datum."ttt <a href=".$link[$i]." target=\"_blank\">".$title[$i]."</a><br>";
}
}
RSSreader();
Alguna idea?
Muchísimas gracias.