Jan 09 2007
BellaBook3.3 RSS 2.0 Feed
Six — via the fanlistings message board — was talking about her script wishlist for 2007 and mentioned a guestbook with RSS 2.0 capabilities. Not one to miss the opportunity to gain a potential user, I offered to knock something up for BellaBook.
The results, which work with version 3.3 are as follows (save it as feed.php in your guestbook directory):
<?php
require_once('config.php');
header('Content-type: text/xml');
echo '<?xml version="1.0" encoding="utf-8"?>'; ?>
<rss version="2.0">
<channel>
<title><?php echo $title; ?></title>
<link><?php echo $admin_url; ?></link>
<description><?php echo $admin_sitename; ?>'s guestbook feed</description>
<language>en-gb</language>
<?php
$blah = file($entriesfile);
$i = 0;
$limit = (count($blah) > 10) ? 10 : count($blah);
while ($i<$limit){
list($name,$email,$url,$date,$ip,$message) = preg_split("/,(?! )/",$blah[$i]);
$date = date("D, d M Y H:i:s T", strtotime($date));
$message = stripslashes($message);
$message = trim($message, ""x00..x1F");
echo "<item>n";
echo "<title>guestbook entry</title>\n";
echo "<link>$admin_url</link>\n";
echo "<pubDate>$date</pubDate>\n";
echo "<description><![CDATA[$message]]></description>\n";
echo "</item>\n";
$i++;
}
?>
</channel>
</rss>
I’m not entirely sure of its use, but who am I to question a request? Anyway, it is there and it works.
At the moment it is limited though; because there is current no individual entry ‘access’ there is no <guid>. Some feed readers don’t like this, and will re-display the entire feed each time it is updated. I will fix this with a new release of BBook, along with new spam-blocking measures some time this month.
Warning
This post is over 6 months old. This means that, despite my best intentions, it may no longer be accurate. Age, motherhood, experience, loss... these things have all changed me from when this blog was started back in the heady (ha) days of my youth.
As much as I would like to go back and edit 10 years of archives to provide an insight into the 'me' of now — to update coding snippets and revise website advice — it would probably take years to do so (by which point I'd have to start again!) This would defeat the point of keeping these archives anyway.
Please take these posts for what they are: a brief look into my past, my history, my journey.
23 Responses so far
-
*Ahem* I wrote a feed for BB a long time ago. /gloat
-
Oh, and mine does have a GUID! :P *Raspyrasp*
-
Waaaah :(
-
Thanks jem, i have finally decided on my new years resolution a bit late i know, and it is do develop a fully working script.
-
ps. to someone who considers herself a grammar whore, it’s is a contraction for “it is” while its is possessive. “I’m not entirely sure of it’s use”
-
That is actually a pretty useful feature to have for a webmaster who doesn’t want to check the guestbook manually for comments. Using a WordPress guestbook myself, I have the option of RSS or emailing of comments — I choose the emailing.
-
I haven’t installed BellaBook on my site yet…DON’T HIT ME, DON’T HIT ME! I have BellaBuffs on one of my random sites, but no one ever goes there (even I don’t…it’s that painful to the eyes).
-
“$blah”, “$blah”. Jeeze spot the shoddy programmer!!! ;) Maybe consider having “feed.xml” re-written to feed.php – people just recognise xml more with rss I think? There’s no reason why the GUID can’t be the post ID or the url (can you can then use isPermalink=”true” on the element if you do that? I haven’t been near RSS for a while).
-
Sorry not the post ID the entry ID – assuming you have have guestbook.php#345454 or “whatever”…
-
Okay, so how do you explain the dodgy variable names,huh? HUH?!
-
I just thought it was very unlike you that’s all. Everything’s usually named properly! Laziness is good though :)
-
I just thought it was very unlike you that’s all. Everything’s usually named properly! Laziness is good though :)
I actually think that it’s a lot like you… Sweet! -
ps. to someone who considers herself a grammar whore, it’s is a contraction for “it is” while its is possessive. “I’m not entirely sure of it’s use” I do believe they’re called “typos” :P
i’m just teasing you.. i thought it was ironic. ;) -
As an unrelated aside, the fixed-width formatting of your code snippet disappears off the right hand side of my browser (normal text just auto-wraps to the column width), but for some reason I get no horizontal scrollbar. I have to maximise my browser to see all the code. Is this your doing or something twisted with my firefox?
-
It does that for me as well, Stephen. Granted, I’m using IE *shames self*, but still. I’m using a 1024×768 resolution, and I’ve pressed F5 several times. Hmm.
-
Jem, thanks so much for whipping this up for me/us! May I admire you? ;)









