How to fetch a feed using PeachRSS
Fetching a feed or portions of a feed is simple with PeachRSS. Below is an example of fetching three fields (title, pubDate and description) from a Wordpress blog feed.
require('peachRSS.inc');
$peach = new peachRSS;
$fields = array("title", "pubDate", "description");
$num_items = $peach->fetch_feed("http://www.myblog.com/feed/", $fields);
echo Items: $num_items <br>";
echo "Generator: " . $peach->items['generator'] . "<br>";
for ($x=0; $x<$num_items; $x++){
echo $peach->items[$x]['title'] . "--" .
$peach->items[$x]['pubDate'] . "<br>" .
$peach->items[$x]['description'] . "<br>";
}
Using PeachRSS to parse tags from a post body
The example below uses PeachRSS's get-tags function to parse tags such as Technorati or UltimateTagWarrior which are signified by the markup "rel=tag".
require('peachRSS.inc');
$peach = new peachRSS;
$fields = array("title", "pubDate", "description", "content:encoded");
$num_items = $peach->fetch_feed("http://www.myblog.com/feed/", $fields);
echo "Items: $num_items <br>";
echo "Generator: " . $peach->items['generator'] . "<br>";
for ($x=0; $x<$num_items; $x++){
$taglist = $peach->get_tags($peach->items[$x]['content:encoded']);
echo $peach->items[$x]['title'] . "--" .
$peach->items[$x]['pubDate'] . "<br>" .
$peach->items[$x]['description'] . "<br>" .
$taglist . "<br>";
}
Please note: the "content:encoded" field must be fetched to use the get-tags function.
