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-usformat=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://turkcesiteler.blogspot.com/feeds/posts/default?alt=rss'); echo $feedlist->display(9,"Türkçe Siteler"); ?> </div> </body> </html>
big thanks for class!
Çok güzel oldu.. tşk.ler
bu class ı sen mi yazdın ?
hayır selman, ingilizce kaynaklardan bulmuştum. kaynak linkini hatırlamıyorum arşivimdeydi .
burda rss in description ve title ınıda almak için ne yapmamız gerek