When you create a website, sometimes you confuse of what content to put or to fulfil inside your website. What about if you can get a content feed right to your website?
Yes, content feed is what you need!!!
There are tons of RSS feed out there that beg you to be aggregated. It is quick and painless by doing this rather than you write the whole blocks.
I will show you how to aggregate this by using PHP.
Please follow the steps below:
1. Download the Magpie scripts from http://magpierss.sourceforge.net
Now, why do I choose Magpie?
MagpieRSS, affectionately known as Magpie, is an RSS and Atom parser for PHP. It allows you to display the newest articles from websites with RSS or Atom feeds on your own site. This is a great way to add new, fresh, and relevant information to your site. It parses RSS 0.9, RSS 1.0, and has some support for RSS 2.0 as well as Atom 0.3
What is the requirement to use Magpie?
Your server must support PHP version 4.2.0 with XML support, or PHP5 with libxml2 support.
2. Simply extract the file and upload the following files to your server: rss_fetch.inc, rss_parser.inc, rss_cache.inc, and rss_utils.inc and the entire directory named extlib. You can put theses files in any directory in the root of your webserver.
3. Here I give you my sample script:
<?php
require_once("magpierss/rss_fetch.inc");
$url = "http://rss.news.yahoo.com/rss/linux";
$rss = fetch_rss( $url );
echo "<b>" . $rss->channel['title'] . "</b><p><ul>";
$ct = 0;
foreach ($rss->items as $item) {
$href = $item['link'];
$title = $item['title'];
$pubDate = $item['pubdate'];
$description = $item['description'];
$ct++;
if ($ct <= 5 ) {
echo "<li><a target='new' href=$href>$title</a><br/>$description
<br/>Publish Date: $pubDate</li> ";
}
}
?>
3. Save your work and try it.
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">

Tidak ada komentar:
Posting Komentar