Page 1 of 1

Auto Generated RSS Feed

Posted: Thu Apr 19, 2012 9:54 pm
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?

Re: Auto Generated RSS Feed

Posted: Thu Apr 19, 2012 10:38 pm
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.

Re: Auto Generated RSS Feed

Posted: Thu Apr 19, 2012 11:23 pm
by Pazuzu156
Do you know a quick fix for this?

Re: Auto Generated RSS Feed

Posted: Fri Apr 20, 2012 1:45 pm
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".