Parameters to RSS Feed ?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Parameters to RSS Feed ?

Post by anjanesh »

Lets say I have in my site word of the day like :
http://dictionary.reference.com/wordoftheday/wotd.rss
Is it possible for me to have another rss feed (meaning.rss) where I give a paramater (meaning.rss?word=hello) which will return the meaning of the word in xml (rss) ?
Thanks
User avatar
n00b Saibot
DevNet Resident
Posts: 1452
Joined: Fri Dec 24, 2004 2:59 am
Location: Lucknow, UP, India
Contact:

Post by n00b Saibot »

Hey, this doesn't belong to PHP-Code does it :x
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Post by anjanesh »

Im pretty sure it does because my question relates to generation of RSS Feeds using PHP.
User avatar
n00b Saibot
DevNet Resident
Posts: 1452
Joined: Fri Dec 24, 2004 2:59 am
Location: Lucknow, UP, India
Contact:

Post by n00b Saibot »

anjanesh wrote:because my question relates to generation of RSS Feeds using PHP.
You didn't mention that before. :roll:
Well, lets see. you want to have a meaning.rss to which you can pass a parameter. You see the fact is RSS is a fixed xml format so it can't just dynamically sort out a meaning.
Maybe you would like to change the target from meaning.rss to meaning.php ;)
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Post by anjanesh »

meaning.php (or meaning.php.rss as this seems to be pasing php) - and output in pure XML format.
But will this validate in a RSS validator and the most important - can other people include these php files ?
If RSS is a fixed xml format then how to sites update things like Latest News, Quote of the Day etc - Im pretty sure they don't manually update - any PHP code within rss ?
User avatar
n00b Saibot
DevNet Resident
Posts: 1452
Joined: Fri Dec 24, 2004 2:59 am
Location: Lucknow, UP, India
Contact:

Post by n00b Saibot »

Methinks they just have rss generators which update the rss files with the updated content. And Yes if the RSS you generate is valid, it can be read by any RSS Reader. :)
User avatar
Buddha443556
Forum Regular
Posts: 873
Joined: Fri Mar 19, 2004 1:51 pm

Post by Buddha443556 »

I think your overlooking one thing. The RSS readers, which checks one address again and again and again. Is the user going to have to update the address every day for the new word meaning? Sort of negates the benefits of using RSS.

You can use PHP to create a "word of the day" RSS feed. It could give the last seven days words in word.rss (or word.php as long as you return the right content-type for RSS readers) with each of the words linked to meaning.php?word=X. This has the added bonus that they return to your site for the meaning thereby developing return traffic. :D
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Post by anjanesh »

Buddha443556 wrote:or word.php as long as you return the right content-type for RSS readers
Thanks Budda. So content-type for RSS readers works if the extension is a .php containing php code. That was what I wanted to know.
User avatar
Buddha443556
Forum Regular
Posts: 873
Joined: Fri Mar 19, 2004 1:51 pm

Post by Buddha443556 »

anjanesh wrote:
Buddha443556 wrote:or word.php as long as you return the right content-type for RSS readers
Thanks Budda. So content-type for RSS readers works if the extension is a .php containing php code. That was what I wanted to know.
The only time I've had trouble with PHP feeds are when they return the wrong content-type. Some readers are more strict than others. As for which one is the right content-type ... well that's a good question? I've been using: application/rss+xml with RSS 0.92.

There's a drew back to using file extension PHP as browsers like Firefox can't find them for the live bookmark indicator. Cron'ing the RSS feed is better for this reason but you could process your RSS files as PHP or do a server side redirect to the php file.
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Post by anjanesh »

Regarding Cronning : what if theres a news feed that keeps updating minute by minute - In that case definitely news.php.rss would be better than to cron a news.rss file - every one minute a cron takes place - doesnt look good.
User avatar
Buddha443556
Forum Regular
Posts: 873
Joined: Fri Mar 19, 2004 1:51 pm

Post by Buddha443556 »

anjanesh wrote:Regarding Cronning : what if theres a news feed that keeps updating minute by minute - In that case definitely news.php.rss would be better than to cron a news.rss file - every one minute a cron takes place - doesnt look good.
It's not how often your news updates that should determine your method of production but the traffic on the feed. Feeds can generate a lot of traffic because they are checked automatically by RSS readers some of which are crap. So if your feed is low traffic fry (php.rss) or bake (cron) it when traffic becomes a problem bake it or throw more hardware at it.
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Post by anjanesh »

I gave these two in the first 2 lines :

Code: Select all

header("Content-type: application/rss+xml");
echo '<?xml version="1.0" encoding="UTF-8"?>';
FF keeps showing the download box - its not showing the xml file.
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

What you can also do is create a php script that, when it runs, overwrites a different .rss file. Or you could configure to parse rss files for PHP. Two ways to keep the right filetype (although I prefer the former)
Post Reply