ccc

RSS: Leer con PHP los rss de un blog de blogger

// Atom 1.0: http://nombredelblog.blogspot.com/feeds/posts/default
// RSS 2.0: http://nombredelblog.blogspot.com/feeds/posts/default?alt=rss

$url = "http://nombredelblog/feeds/posts/default?alt=rss";

$articulos = simplexml_load_string(file_get_contents($url));
$num_noticia = 1;
$max_noticias = 10;
foreach($articulos->channel->item as $noticia){ ?>
    <article>
        <h1><a href="<?php echo $noticia->link; ?>"><?php echo utf8_decode($noticia->title); ?></a></h1>
        <?php echo utf8_decode($noticia->description); ?>
    </article>
    <?php
$num_noticia++;
       if($num_noticia > $max_noticias){
break;
       }
}

No hay comentarios:

Publicar un comentario