Auto Generated 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
Pazuzu156
Forum Contributor
Posts: 241
Joined: Sat Nov 20, 2010 9:00 pm
Location: GA, USA
Contact:

Auto Generated RSS Feed

Post by Pazuzu156 »

I have a PHP file that takes the news feed from my database and extracts it and places it into xml code to show as an RSS feed. To make it like so, I changed the header to

Code: Select all

header("Content-type: application/rss+xml; charset=ISO-8859-1");
When I comment this out, it runs ok, but displays as a web page. When it's in use, it forces the browser to download the file. Why is it doing this?
- Kaleb Klein
------------------------------------
Web Developer | Software Developer
https://kalebklein.com
PGP Key: https://keybase.io/pazuzu156
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Auto Generated RSS Feed

Post by Christopher »

HTTP headers are one of the ways that the program receiving the data knows what the data is. By default, web servers send headers telling the client that the data is a web page. For other kinds of data you need to set the headers to tell the client what kind of data it is.
(#10850)
User avatar
Pazuzu156
Forum Contributor
Posts: 241
Joined: Sat Nov 20, 2010 9:00 pm
Location: GA, USA
Contact:

Re: Auto Generated RSS Feed

Post by Pazuzu156 »

Do you know a quick fix for this?
- Kaleb Klein
------------------------------------
Web Developer | Software Developer
https://kalebklein.com
PGP Key: https://keybase.io/pazuzu156
x_mutatis_mutandis_x
Forum Contributor
Posts: 160
Joined: Tue Apr 17, 2012 12:57 pm

Re: Auto Generated RSS Feed

Post by x_mutatis_mutandis_x »

Content-type "application/..." is going to force a download in most of the browsers. Try using "text/xml" instead of "application/rss+xml".
Post Reply