Jump to content


Photo

automating rss enclosure creation in php


  • Please log in to reply
1 reply to this topic

#1 bullchina

bullchina
  • Members
  • PipPip
  • Member
  • 19 posts
  • LocationHouston

Posted 19 September 2006 - 09:02 AM

I am creating a small script to output news info from a database into rss format, and I want the ability to include enclosures, but I want it to be as easy as possible for any person to update the database. the enclosure item in an rss feed requires a url, the length in bytes of the file, and the filetype.

I am using the filesize() function to get the bytes, so the user doesn't have to input that element into the database, but is there a more automated way of adding the file type attribute, without creating a huge switch statement? I can't seem to find anything about this, but I also don't really know what terms to search for. I suppose the switch statement won't be that big, but I thought there may be a better way to automate this process.

Thanks for your help,
dave

#2 bullchina

bullchina
  • Members
  • PipPip
  • Member
  • 19 posts
  • LocationHouston

Posted 19 September 2006 - 09:29 AM

ok, i found something called finfo_open(FILEINFO_MIME); which is supposed to give back the mime type (i forgot that word...).

i guess you have to have a pear fileinfo module installed to get that to work.

also, i found that the filesize function will not work with absolute http url's. it must be a local file.

then i saw that readfile() will return the number of bytes of any file, but that seems a little inefficient. I think it's a better idea for me to store the local path to the file relative to the site root in the database, and then appen the doc_root upon outputting the rss...

is that right, or is there a better way?




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users