Archive for May, 2011

Exporting facebook events to google calendar

Saturday, May 21st, 2011

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>