Skip to content

Instantly share code, notes, and snippets.

@xombra
Created January 1, 2015 18:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save xombra/dfe6556bab7baad4b586 to your computer and use it in GitHub Desktop.
Save xombra/dfe6556bab7baad4b586 to your computer and use it in GitHub Desktop.
#
# Lee un RSS/XML de una url determinada
#
function RSS($url,$imagen)
{ global $entries;
if (VERIFICA_ONLINE($url)){
$noticias = simplexml_load_file($url);
$largo=700;
$lee=3;
$ciclo = 1;
foreach ($noticias as $noticia) {
foreach($noticia as $reg){
if(!empty($reg->title) && $ciclo<$lee&& !empty($reg->description)){
$pubdate = $reg->pubDate;
$title = $reg->title;
$link = $reg->link;
$description = strip_tags(substr($reg->description,0,$largo)).'...';
$timestamp = strtotime(substr($reg->pubDate,0,25));
$entries[$timestamp]['pubdate'] = $timestamp;
$entries[$timestamp]['title'] = $title;
$entries[$timestamp]['link'] = $link;
$entries[$timestamp]['image'] = $imagen;
$entries[$timestamp]['description'] = $description;
$ciclo++;
}
}
}
}
return $entries;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment