For Programmers: Free Programming Magazines  


Home > Archive > PHP Programming > November 2007 > php with rss









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author php with rss
Ciaran

2007-11-29, 7:03 pm

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
Ciaran

2007-11-29, 7:03 pm

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
Rik Wasmus

2007-11-29, 7:03 pm

On Thu, 29 Nov 2007 22:33:23 +0100, Ciaran <cronoklee@hotmail.com> 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
Ciaran

2007-11-29, 7:03 pm

On Nov 29, 9:47 pm, "Rik Wasmus" <luiheidsgoe...@hotmail.com> wrote:
> On Thu, 29 Nov 2007 22:33:23 +0100, Ciaran <cronok...@hotmail.com> wrote:
>
> 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 , I wasn't expecting it to be that easy! So rss readers don't
have any problem looking up a .php file?
Rik Wasmus

2007-11-29, 7:03 pm

On Thu, 29 Nov 2007 23:06:33 +0100, Ciaran <cronoklee@hotmail.com> wrote:

> On Nov 29, 9:47 pm, "Rik Wasmus" <luiheidsgoe...@hotmail.com> wrote:
>
> oh , 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
Ciaran

2007-11-29, 7:03 pm

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
Rik Wasmus

2007-11-29, 7:03 pm

On Thu, 29 Nov 2007 23:44:43 +0100, Ciaran <cronoklee@hotmail.com> 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: <?xml version=3D"1.0" encoding=3D"utf-8"?>
2: <?xml-stylesheet type=3D"text/css" [>]

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

Use a validator in your testing: =

<http://validator.w3.org/feed/check....Fwww.scouttalk=
..ie%2Frsstest.php> =

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

Rik Wasmus
Ciaran

2007-11-30, 8:02 am

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
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com