Archive for the ‘PHP’ Category.

Simple Facebook Connect Integration

I found an interesting plugin for this wordpress blog when I was going through my RSS feeds a couple of weeks ago. Simple Facebook Connect allows blog commenters to post using their Facebook accounts for authentication. Not only that, it leaves a link back to their profile as well as showing their avatar (depending on privacy settings). I’ve installed the plugin on this blog, which you can try out by going to a post, and selecting “Connect with Facebook” on the sidebar.

I did note, however, that the FB avatar wasn’t being displayed correctly (alignment was broken) with the current theme, Fluid Blue. Needed to edit “simple-facebook-connect/sfc-comments.php” and replace the two relevant blocks that generates the picture displaying HTML with:

$avatar = "";

Facebook Event + Google Calendar Integration

When using the Facebook Events calendar feed within Google Calendar, many events show up only as “busy” instead of their proper name. This is because Google Calendar does not handle events with “CLASS:PRIVATE” properly.

The following PHP script is something that was thrown together quickly that grabs the feed from Facebook, replaces “CLASS:PRIVATE” with “CLASS:PUBLIC” and outputs it. Just edit the script to match your personal URL, then upload it on a PHP enabled server. Point Google Calendar to this file, and you should be able to view all your events properly again.

<?php
header('Content-type: text/calendar');
$url = "YOUR_FACEBOOK_URL_HERE"; //starts with http://www.facebook.com/ical/...
$pagetext = file_get_contents($url);
$pagetext = str_replace("CLASS:PRIVATE", "CLASS:PUBLIC", $pagetext);
echo $pagetext;
?>