Webmaster Key - Discussion Forums


Welcome, Guest. Please login or register.
Did you miss your activation email?
February 09, 2012, 06:41:00 PM

Login with username, password and session length
Welceome to Forums!

Important information for guests and new members:

In order to understand the full benefits of becoming an active member of this forum, please review the following information on guest and new member restrictions. These forum changes have been prompted by an overwhelming and unreasonable amount of bot postings and incoherent guest spam messages. We wish to prevent these events from happening in the future and make our community a more comfortable place for all of our members.

For guests:

Guests are not allowed to open new topics, polls, or posts attachments.
If you wish to open up new discussions on this forum, we encourage you to register.

For new members:

New members with less than five posts are not allowed to modify additional profile information such as avatars, contact information, biographies, and signatures. However, new members are encouraged to post their own topics or reply to topics initiated by other members. Become active on the forums and 5 posts should be an easy task!

We are a diverse community with members from all over the world. We encourage new ideas and interesting conversation. Do not be afraid to post webmaster/computer-related questions or problems, as our active members are always willing to help when they are able. Interested? Join us.

+ Webmaster Key Forums
|-+ Webmaster Corner
| |-+ Site Design and Web Authoring
| | |-+ Coding Talk
| | | |-+ RSS Feed Script
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] Go Down Stumble Upon! Digg It! del.icio.us! Add to Technorati! ReddIt!  Send this topic Print
Author Topic: RSS Feed Script  (Read 2486 times)
Andy
Administrator
Veteran
*****
Posts: 5 752



« on: October 10, 2007, 12:03:36 PM »

Here is a simple way to include an RSS feed in your web page using PHP:

First you need to download some code from: http://sourceforge.net/projects/magpierss/

Then here is some simple PHP code to include on a page to show the feed:

Code:
<?php
require_once 'rss_fetch.inc';

$url $_GET['url'];

$rss fetch_rss($url);

echo 
"Site: "$rss->channel['title'], "<br />
<ul>
"
;
foreach (
$rss->items as $item ) {
$title $item[title];
$url   $item[link];
echo "<li><a href=$url>$title</a></li>
"
;
}
?>

</ul>

the feed is specified in the GET variable i.e. rss-script.php?url=http://feedlink

or you could hard code it like: $url = "http://feedlink";
Report to moderator   Logged

Andy
Administrator
Veteran
*****
Posts: 5 752



« Reply #1 on: October 12, 2007, 09:09:30 AM »

The code I posted to get hold of a feed and display on your site does more than just grab the feed, it caches the feed on your site so your page is quick to load after the first feed download and you don't overburden the feed server to annoy them.

Producing your own RSS feed is really easy, it's just a matter of providing a simple XML page and linking to it from say an RSS feed icon on your page.

There is a good tutorial on how to do it here: http://www.xul.fr/en-xml-rss.html

I went a step further and wrote php code to generate my XML file from a database.

To call the PHP script from a request for the XML file I used .htaccess (available on Apache server hosting) as follows:

Code:
RewriteEngine On
RewriteRule ^feed.xml$ feed.php

This runs the code in feed.php thats spits out the source text of the xml file but the feed reader sees a file called feed.xml

No I don't want to reveal my code for feed.php  Wink

If you don't run a blog (where RSS feeds are a standard component) it makes sense to include an RSS feed on your home page with updates and news from your site so visitors may subscribe to your feed which is more powerful than simply bookmarking your site.

You can see my feed here:

http://initialtraffic.com/feed.xml

View the source in your browser to see how simple the file is. You could create your own one in a text editor and save it to your site as feed.xml then link to it via a hypertext link.
« Last Edit: October 12, 2007, 09:19:27 AM by Andy » Report to moderator   Logged

Pages: [1] Go Up Stumble Upon! Digg It! del.icio.us! Add to Technorati! ReddIt!  Send this topic Print 
+ Webmaster Key Forums
|-+ Webmaster Corner
| |-+ Site Design and Web Authoring
| | |-+ Coding Talk
| | | |-+ RSS Feed Script

Jump to:  
« previous next »


Our Partners
RelmaxTOP Ranking System Web Hosting RelmaxTOP Ranking System
Staff Sites
12Noon[12Noon Gallery] Andy[Urgentclick]
Tamuril[Tamuril's Digital Art Exhibit] Sensovision
Powered by MySQL Powered by PHP We are hosted by Relmax Inc. |Our Privacy Policy | Sitemap
Powered by SMF 1.1.9 | SMF © 2006-2009, Simple Machines LLC
Forum design by Tamuril © 2005.
Valid XHTML 1.0! Valid CSS!