Bu konu web geliştiriciler için bazı zamanlar çok önemli bir mesele halini almaktadır. RSS beslemesi olan herhangi bir websitenin RSS beslemelerini RSSCLASS sınıfımız ile düzenli bir şekilde okuyabiliriz.

Kodlarımızı yazalım:
rssclass.php
<?php
class rss {
var $feed;
function rss($feed)
{ $this->feed = $feed; }
function parse()
{
$rss = simplexml_load_file($this->feed);
$rss_split = array();
foreach ($rss->channel->item as $item) {
$title = (string) $item->title; // Title
$link = (string) $item->link; // Url Link
$description = (string) $item->description; //Description
$rss_split[] = '<div>
<a href="'.$link.'" target="_blank" title="" >
'.$title.'
</a>
<hr>
</div>
';
}
return $rss_split;
}
function display($numrows,$head)
{
$rss_split = $this->parse();
$i = 0;
$rss_data = '<div>
<div>
'.$head.'
</div>
<div>';
while ( $i < $numrows )
{
$rss_data .= $rss_split[$i];
$i++;
}
$trim = str_replace('', '',$this->feed);
$user = str_replace('&lang=en-us&format=rss_200','',$trim);
$rss_data.='</div></div>';
return $rss_data;
}
}
?>
index.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
.vas{
float:left;
width:270px;
padding:10px;
}
#panel{
color:#333;
background-color:#C8E6E2;
width:100%;
}
.title-head {
font-size:18px;
font-weight:bold;
text-align:left;
background-color:#CDA33F;
color:#FFFFFF;
padding:5px;}
.feeds-links {
text-align:left;
padding:5px;
}
</style>
<title>Serpito.com - RSS Feed Demo</title></head>
<body>
<div id="panel">
<center><h2>Serpito.com</h2>
Bu demo <a href="http://www.serpito.com/php-rss-besleme-okumak/">PHP: RSS besleme okumak</a> yazısı icin hazirlanmistir.
</center>
</div>
<div>
<?php
include('rssclass.php');
$feedlist = new rss('http://feeds2.feedburner.com/serpito');
echo $feedlist->display(9,"Serpito.com");
$feedlist = new rss('http://www.gumusluoglu.com/feed/');
echo $feedlist->display(9,"Gumusluoglu.com");
$feedlist = new rss('http://yedincisenol.wordpress.com/feed/');
echo $feedlist->display(9,"Yedincisenol");
$feedlist = new rss('http://www.molgun.com/feed');
echo $feedlist->display(9,"Molgun.com");
?>
</div>
</body>
</html>
Uygulamanın çalışır demosunu incelemek için tıklayınız.
Uygulama dosyalarını zip şeklinde indirmek için tıklayınız.




January 18th, 2010
admin
Posted in 
