php with rss

php with rss

am 29.11.2007 22:29:51 von cronoklee

Hi i'm just experimenting here with php and rss and I'm wondering if
it's possible to point an rss reader to a php script? I'd like to
dynamically pull data out of an SQL table as the viewer checks the
feed. Is this possible please?
Cheers,
Ciar=E1n

Re: php with rss

am 29.11.2007 22:33:23 von cronoklee

Sorry I should have mentioned - I'm very familiar with php and sql so
I'm really just asking if its possible in theory. All I need is a
general overview of how it works.
Cheers,
Ciar=E1n

Re: php with rss

am 29.11.2007 22:47:22 von luiheidsgoeroe

On Thu, 29 Nov 2007 22:33:23 +0100, Ciaran wrote:
> Sorry I should have mentioned - I'm very familiar with php and sql so
> I'm really just asking if its possible in theory. All I need is a
> general overview of how it works.

Yes. Instead of outputting HTML as is most common, just output the XML
needed for an rss feed. Several XML packages can make it easier for you,
no strict requirement though: simple echo/print would do. So examine the
format in one of thousands of rss tutorials, make sure your PHP output
conforms to that format and you're done. (Well, output a right
content-type header, but that's it).
--
Rik Wasmus

Re: php with rss

am 29.11.2007 23:06:33 von cronoklee

On Nov 29, 9:47 pm, "Rik Wasmus" wrote:
> On Thu, 29 Nov 2007 22:33:23 +0100, Ciaran wrote:
> > Sorry I should have mentioned - I'm very familiar with php and sql so
> > I'm really just asking if its possible in theory. All I need is a
> > general overview of how it works.
>
> Yes. Instead of outputting HTML as is most common, just output the XML
> needed for an rss feed. Several XML packages can make it easier for you,
> no strict requirement though: simple echo/print would do. So examine the
> format in one of thousands of rss tutorials, make sure your PHP output
> conforms to that format and you're done. (Well, output a right
> content-type header, but that's it).
> --
> Rik Wasmus


oh cool, I wasn't expecting it to be that easy! So rss readers don't
have any problem looking up a .php file?

Re: php with rss

am 29.11.2007 23:19:59 von luiheidsgoeroe

On Thu, 29 Nov 2007 23:06:33 +0100, Ciaran wrote:

> On Nov 29, 9:47 pm, "Rik Wasmus" wrote:
>> On Thu, 29 Nov 2007 22:33:23 +0100, Ciaran
>> wrote:
>> > Sorry I should have mentioned - I'm very familiar with php and sql so
>> > I'm really just asking if its possible in theory. All I need is a
>> > general overview of how it works.
>>
>> Yes. Instead of outputting HTML as is most common, just output the XML
>> needed for an rss feed. Several XML packages can make it easier for you,
>> no strict requirement though: simple echo/print would do. So examine the
>> format in one of thousands of rss tutorials, make sure your PHP output
>> conforms to that format and you're done. (Well, output a right
>> content-type header, but that's it).
>
> oh cool, I wasn't expecting it to be that easy! So rss readers don't
> have any problem looking up a .php file?

Well, as long as the php file runs. Browser, rss-readers, soapclients,
etc. have no way of knowing for sure you use PHP, and they don't really
care. As long as you throw out a valid content-type & output they're happy.
--
Rik Wasmus

Re: php with rss

am 29.11.2007 23:44:43 von cronoklee

Great OK sounds promising. I have set up a test file with
header("Content-Type: application/rss+xml"); when I visit the page my
browser is trying to download the php file. Have I done something
wrong?

http://www.scouttalk.ie/rsstest.php

Re: php with rss

am 29.11.2007 23:52:26 von luiheidsgoeroe

On Thu, 29 Nov 2007 23:44:43 +0100, Ciaran wrote=
:

> Great OK sounds promising. I have set up a test file with
> header("Content-Type: application/rss+xml"); when I visit the page my
> browser is trying to download the php file. Have I done something
> wrong?
>
> http://www.scouttalk.ie/rsstest.php

XML is not (should not) be just like tagsoup HTML: you really have to ta=
ke =

care of correct syntax. Opera says this:
Error!
XML parsing failed
XML parsing failed: syntax error (Line: 2, Character: 33)

Reparse document as HTML
Error:invalid xml-stylesheet processing instruction
Specification:http://www.w3.org/TR/REC-xml/
1:
2: ]

So, end with ?>, not with >...

Use a validator in your testing: =

..ie%2Frsstest.php> =

would tell you what it can't process.
-- =

Rik Wasmus

Re: php with rss

am 30.11.2007 14:13:32 von cronoklee

Ah! OK great, thanks a million Rik! I got that code from some rss
template - I didn't notice or expect there to be errors in it. I
appreciate the help, I think I can handle it from here!
Best of luck,
Ciar=E1n