RSS reader in PHP, compatible with ccHost 4.5
diumenge, març 8th, 2009Here a plugin for ccHost 4.5 or 5 to get RSS feeds and show them on your cchost_files/*.xml . It may be used out of ccHost without problems. Written in PHP5. License GPL
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | <?php function getRSS($feed, $limit = 3) { // $feed must be a valid RSS url. // the function will return an array with the basic information for our news. // print_r($RSSData); for further information. // License: GPL - Eduard Gamonal <edu at eduard-gamonal dot net> $feedData = file_get_contents($feed); $RSSData = new SimpleXMLElement($feedData); $news = array(); $c = count($RSSData->channel->item); for ($i = 0; $i < $limit and $i < $c; $i++) { $news[$i]['title'] = (string)$RSSData->channel->item[$i]->title; $news[$i]['link'] = (string)$RSSData->channel->item[$i]->link; $news[$i]['pubDate'] = (string)$RSSData->channel->item[$i]->pubDate; $news[$i]['description'] = (string)$RSSData->channel->item[$i]->description; } return $news; } ?> |