Jump to content


Photo

PHP & RSS


  • Please log in to reply
5 replies to this topic

#1 Gaia

Gaia
  • Members
  • PipPipPip
  • Advanced Member
  • 95 posts
  • LocationCanada

Posted 08 March 2006 - 08:17 PM

hi,

I want to be able to export some data from a mySQL table to a rss file ( .rss ). So basically i want to create a .rss file for syndication on other websites.

How can you do that via PHP? If anyone can get me started or point me to a resource/tutorial or a section in the PHP Manual that discusses this?

Thanks.

#2 XenoPhage

XenoPhage
  • Members
  • PipPipPip
  • Advanced Member
  • 99 posts

Posted 08 March 2006 - 09:38 PM

[!--quoteo(post=352961:date=Mar 8 2006, 03:17 PM:name=Gaia)--][div class=\'quotetop\']QUOTE(Gaia @ Mar 8 2006, 03:17 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
hi,

I want to be able to export some data from a mySQL table to a rss file ( .rss ). So basically i want to create a .rss file for syndication on other websites.

How can you do that via PHP? If anyone can get me started or point me to a resource/tutorial or a section in the PHP Manual that discusses this?

Thanks.
[/quote]

I created my own object to do this. You can use the code if you like, it's part of my [a href=\"http://www.sourceforge.net/projects/phptodo\" target=\"_blank\"]phpTodo[/a] project.
--
[a href=\"http://blog.godshell.com\" target=\"_blank\"]XenoPhage[/a]
[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Something mysterious is formed, born in the silent void. Waiting alone and unmoving, it is at once still and yet in constant motion. It is the source of all programs. I do not know its name, so I will call it the Tao of Programming.[/quote]

#3 Gaia

Gaia
  • Members
  • PipPipPip
  • Advanced Member
  • 95 posts
  • LocationCanada

Posted 09 March 2006 - 02:22 PM

Thanks, but i'd rather learn how to do it myself and create my own function/class. Do you remember any of the resources/tutorials you used that helped you create your object?

Thanks ^_^

#4 XenoPhage

XenoPhage
  • Members
  • PipPipPip
  • Advanced Member
  • 99 posts

Posted 09 March 2006 - 03:57 PM

[!--quoteo(post=353251:date=Mar 9 2006, 09:22 AM:name=Gaia)--][div class=\'quotetop\']QUOTE(Gaia @ Mar 9 2006, 09:22 AM) View Post[/div][div class=\'quotemain\'][!--quotec--]
Thanks, but i'd rather learn how to do it myself and create my own function/class. Do you remember any of the resources/tutorials you used that helped you create your object?

Thanks ^_^
[/quote]

Sure.. I looked up the specs for RSS 0.90, 1.0, and 2.0. I used those to figure out what the structure looked like, and then built a class to output that data. Here are some links for RSS :

[a href=\"http://backend.userland.com/rss092\" target=\"_blank\"]RSS 0.92 Spec[/a]
[a href=\"http://blogs.law.harvard.edu/tech/rss\" target=\"_blank\"]RSS 2.0 Spec[/a]

[a href=\"http://web.resource.org/rss/1.0/\" target=\"_blank\"]RSS 1.0 Spec[/a]

[a href=\"http://atompub.org/2005/07/11/draft-ietf-atompub-format-10.html\" target=\"_blank\"]Atom 1.0 Spec[/a]

NOTE : RSS 1.0 is *NOT* compatible with 2.0 ... Read the history. 1.0 is basically an off-shoot from 0.90 and developed independently from 2.0. 2.0 was named such so as to not confuse people..
--
[a href=\"http://blog.godshell.com\" target=\"_blank\"]XenoPhage[/a]
[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Something mysterious is formed, born in the silent void. Waiting alone and unmoving, it is at once still and yet in constant motion. It is the source of all programs. I do not know its name, so I will call it the Tao of Programming.[/quote]

#5 obsidian

obsidian
  • Staff Alumni
  • Advanced Member
  • 3,202 posts
  • LocationSeattle, WA

Posted 09 March 2006 - 04:27 PM

gaia, keep in mind that when an RSS reader hits a page, they typically do not care of the actual extension name, they only care about the actual mime type of the file. if you have it reading as XML and you have your generated feed valid, you can simply have a .php file that creates it on the fly. for instance, here is one that i created for the student newspaper at the university i work at: [a href=\"http://www.bju.edu/collegian/rss/index.php\" target=\"_blank\"]http://www.bju.edu/collegian/rss/index.php[/a]. it very simply pulls the information and dynamically generates the feed every time the page loads.

the nice thing about doing it this way is that if you have someone accessing your feed for synication, every single time they make a request, it's live, so any corrections or changes are immediately represented. notice that it's actually a .php file that's making the call, yet it renders as a validated RDF file.

hope this helps get you going in the right direction.
You can't win, you can't lose, you can't break even... you can't even get out of the game.

<?php
while (count($life->getQuestions()) > 0)
{   $life->study(); } ?>
  LINKS: PHP: Manual MySQL: Manual PostgreSQL: Manual (X)HTML: Validate It! CSS: A List Apart | IE bug fixes | Zen Garden | Validate It! JavaScript: Reference Cards RegEx: Everything RegEx

#6 obsidian

obsidian
  • Staff Alumni
  • Advanced Member
  • 3,202 posts
  • LocationSeattle, WA

Posted 09 March 2006 - 04:29 PM

btw, RDF is simply another syntax available for your RSS
You can't win, you can't lose, you can't break even... you can't even get out of the game.

<?php
while (count($life->getQuestions()) > 0)
{   $life->study(); } ?>
  LINKS: PHP: Manual MySQL: Manual PostgreSQL: Manual (X)HTML: Validate It! CSS: A List Apart | IE bug fixes | Zen Garden | Validate It! JavaScript: Reference Cards RegEx: Everything RegEx




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users