Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

pulsewidth947

macrumors 65816
Original poster
Jan 25, 2005
1,106
2
I just spent the past hour making a PHP RSS feed for my site and I just thought I'd boast. Ok I know its nothing terribly advanced with PHP, but I've only been using it for a month or so, and its quite a big achievement for me (firstly its the first loop i've coded, secondly its the first time I've had to trick the browser into thinking the file is something its not). I also taught myself how incredibly useful the UNIX_TIMESTAMP and date() functions are... wow!

So now when I add a new song/picture to my website it automatically creates a new entry in my RSS SQL table, as well as adding itself to my news table, and of course in the relevant section. Not that difficult but its great the amount of time it should save me - especially if all of my site was done using html pages. Thats 3 lots of information I'd have to copy and paste in!

I think I need to make myself a widget to update all this information from my dashboard!

Oh yeah this is all to do with putting off getting my site to look normal in Windows Internet Explorer :p
 

mrjamin

macrumors 65816
Feb 6, 2003
1,161
1
Strongbadia
Good work!

Here's some all important functions i've come accross in my own RSS creation:

PHP:
// convert timestamp to ISO8601 formatted date
function iso8601_date($time){
	$tzd = date('O',$time);
	$tzd = substr(chunk_split($tzd, 3, ':'),0,6);
	$date = date('Y-m-d\TH:i:s', $time) . $tzd;
	return $date;
}

// convert special chars to UTF-8 valid entities
function strictify ( $string ) {
	$fixed = htmlspecialchars( $string, ENT_QUOTES );
	$trans_array = array();
	for ($i=127; $i<255; $i++) {
		$trans_array[chr($i)] = "&#" . $i . ";";
	}
	$really_fixed = strtr($fixed, $trans_array);
	return $really_fixed;
}
 

pulsewidth947

macrumors 65816
Original poster
Jan 25, 2005
1,106
2
Ahh yours looks much more watertight.

I used
$timestamp = $r['timestamp'];
$date = date("r", $timestamp);
for my date. r = RFC 2822 formatted date, havent seen to come accross any problems yet.

Whats the max length of the <title> in a rss feed?

Your sig brings back many memories :p
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.