Exporting facebook events to google calendar

Update:This script has been updated to update dates on full day events as well.

Just a small php script I’ve been using so Google Calendar actually shows private facebook events on your calendar.
For some reason when Google Calendar sees an ics file with it’s class set to private, it thinks even you shouldn’t be able to see it on your own calendar :\

Get the ical link from facebook by clicking ‘export events’ on this page:
https://www.facebook.com/?sk=events&ap=1

<?php

$ical = "*link here*";

$file=file_get_contents($ical);
$search="CLASS:PRIVATE";
$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);
?php>

One Response to “Exporting facebook events to google calendar”

  1. Psykar says:

    […] a while ago I wrote a php script to make facebook event names appear properly on google calendar. I’ve since noticed that all ‘full day’ events on facebook get […]

Leave a Reply

You\'re not a robot are you? *