Wednesday, May 6, 2009

Read yahoo groups rss by curl and SimpleXmlElement in PHP

..< ?php
// Read yahoo groups rss by curl and SimpleXmlElement
// by Amit gaur  $url = "http://rss.groups.yahoo.com/group/tm_informatikleri/rss"; $req = curl_init(); curl_setopt($req, CURLOPT_URL, $url);
curl_setopt($req, CURLOPT_RETURNTRANSFER, 1);
$xml = curl_exec($req);
curl_close($req);
$doc = new SimpleXmlElement($xml, LIBXML_NOCDATA);
if(isset($doc->channel))
{
showRSS($doc);
}
function showRSS($xml)
{
echo "".$xml->channel->title."
";
$cnt = count($xml->channel->item);
for($i=0; $i<$cnt; $i++)
{
$url = $xml->channel->item[$i]->link;
$title = $xml->channel->item[$i]->title;
$desc = $xml->channel->item[$i]->description;
$pubDate=$xml->channel->item[$i]->pubDate;
echo ''.$title.'
'.$pubDate.'
'.$desc. ' '. $guid. '

';
}
}
?>

No comments:

Post a Comment