Leer Contenido de feed/rss con [PHP]
Para leer el contenido de el feed o el rss hay muchas paginas de internet, pero aquí te muestro un class para leer el feed o rss de tu web con solo poner la url en el class, puedes inventar tu propia forma de mostrar el contenido.
<?
class RssReader {
var $url;
var $data;
function RssReader ($url){
$this->url;
$this->data = implode ("", file ($url));
}
function get_items (){
preg_match_all ("/<item .*>.*<\/item>/xsmUi", $this->data, $matches);
$items = array ();
foreach ($matches[0] as $match){
$items[] = new RssItem ($match);
}
return $items;
}
}
class RssItem {
var $title, $url, $description;
function RssItem ($xml){
$this->populate ($xml);
}
function populate ($xml){
preg_match ("/<title> (.*) <\/title>/xsmUi", $xml, $matches);
$this->title = $matches[1];
preg_match ("/<link> (.*) <\/link>/xsmUi", $xml, $matches);
$this->url = $matches[1];
preg_match ("/<description> (.*) <\/description>/xsmUi", $xml, $matches);
$this->description = $matches[1];
}
function get_title (){
return $this->title;
}
function get_url (){
return $this->url;
}
function get_description (){
return $this->description;
}
}
?>
Para llamar los datos incluimos la class ya mencionada y lo interpretamos así
<?
include('class.php');//archivo donde este el class
$rss = new RssReader ("http://dedydamy.com/<b style="color: black; background-color: rgb(255, 255, 102);">feed</b>");//aqui donde esta http://dedydamy.com/<b style="color: black; background-color: rgb(255, 255, 102);">feed</b> tienes que poner la url de tu <b style="color: black; background-color: rgb(255, 255, 102);">feed</b> o rss
foreach ($rss->get_items () as $item){ //aca hacemos un foreach para el array de las entradas que se muestren en el <b style="color: black; background-color: rgb(255, 255, 102);">feed</b>
echo($item->get_title()."<br />");//escribimos titulo
echo($item->get_url()."<br />");///url del post
echo($item->get_description()."<br />");//descripcion o lo principal del post
echo("<hr><br />");
}
?>
Gracias por la info, lo único que no puedo levantar el titulo del feed!
Que puede ser?