Revision: 30065
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at August 6, 2010 21:59 by jrobinsonc
Initial Code
function lectorRSS($url,$elementos=6,$inicio=0) {
$cache_version = "cache/" . basename($url);
$archivo = fopen($url, 'r');
stream_set_blocking($archivo,true);
stream_set_timeout($archivo, 5);
$datos = stream_get_contents($archivo);
$status = stream_get_meta_data($archivo);
fclose($archivo);
if ($status['timed_out']) {
$noticias = simplexml_load_file($cache_version);
}
else {
$archivo_cache = fopen($cache_version, 'w');
fwrite($archivo_cache, $datos);
fclose($archivo_cache);
$noticias = simplexml_load_string($datos);
}
$ContadorNoticias=1;
echo "<ul>";
foreach ($noticias->channel->item as $noticia) {
if($ContadorNoticias<$elementos){
if($ContadorNoticias>$inicio){
echo "<li><a href='".$noticia->link."' target='_blank' class='tooltip' title='".utf8_decode($noticia->title)."'>";
echo utf8_decode($noticia->title);
echo "</a></li>";
}
$ContadorNoticias = $ContadorNoticias + 1;
}
}
echo "</ul>";
}
Initial URL
Initial Description
La siguiente función muestra los tÃtulos, junto con los enlaces, cargados de un RSS.
Initial Title
Función para leer y mostrar un RSS con PHP
Initial Tags
Initial Language
PHP