Modified Facebook FBCal to show private events in Gmail Calendar


Recommended Posts

Hi,

Firstly, apologies to mods if this is in the wrong place. I've spent a bit of time modifying the code from gsellis.com (http://www.gsellis.com/2009/06/fbcal/) to solve a common problem and thought I'd post it here in case others want to use it.

There is a known problem with Google Calendar (gCal) and Facebook (FB) whereby private events in Facebook simply show up as "busy" entries in gCal when exported. This is frustrating since the iCal file contains all the data and gCal simply displays it wrong. Gsellis wrote code to obtain the iCal file from FB, set all private flags to public and then output a new iCal file which gCal displayed correctly.

However, I didn't want to just use the FB iCal file as it doesn't show past events and you can't choose whether or not to see events you're not attending / haven't replied to yet. These features are offered by a handy FB app called "FBcal" but the 'private events showing as busy' problem arises again. Therefore, I found a solution using this code:

**Save in a file on your hosting - e.g. cal.php**Add calendar by url in gCal: http://www.yourhost.com/cal.php**

<?php
$ical="**The URL given to you by FBCal - unique for each user and choice of display options**";
$file=file_get_contents($ical);
$search="CLASS:CONFIDENTIAL";
$replace="CLASS:PUBLIC";
$output=str_replace($search,$replace,$file);
header("Content-Type: text/Calendar");
// Give the file a name and force download
header("Content-Disposition: inline; filename=events.ics");
print_r($output);
?>

This requires the FBCal link to be hardcoded as I wasn't sure of the format it took. Mine was:

http://www.fbcal.com/cal/{UID}/40d32f39d2721c1582498520-{UID}/events/ics/attending,unsure/tz/Europe-Dublin

where UID is a unique user ID given in the simple facebook export events link when you login to FB. The facebook link also includes a key, but I'm not sure how this relates to the other string of characters in the link.

So, if other people have had this problem and want to work out how to make it into a general script which can be hosted once and used by many people then that's fine. Equally, if no-one has had this problem and it's just me being picky with my calendar preferences then feel free to consign this to the bin!

EDIT: Just realised the title should be Google Calendar, not Gmail calendar... perhaps a mod could change it to "How to modify Facebook app 'FBCal' to properly display private events in Google Calendar" - Thanks!

Link to comment
Share on other sites

  • 3 weeks later...
  • 3 weeks later...
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.