Adding iCloud Calendar Subscriptions to Google Calendar

If you’ve ever tried to subscribe to a public iCloud Calendar from Google Calendar then you have, no doubt, discovered that it doesn’t work.

The problem stems from Apple’s use of the robots.txt file on it’s calendar servers to prevent the indexing of public calendar data by index spiders from Google, Yahoo and others. Google has a policy of always respecting the contents of these files which means they reject the inclusion of iCloud calendar subscriptions from within Google Calendar.

robots

My wife is an iPhone user, which is where she keeps the “master family calendar” which she, in-turn, syncs to iCloud. Not having her calendar information on my calendar simply isn’t an option. Thinking about this for a moment, I thought to use an intermediate program that would pull her calendar data from iCloud and present it to my Google Calendar, exactly as if I were pulling the data directly from the iCloud servers.

For this to work, you need to, obviously, have access to a publicly available http server where you can drop the following file into the www root, make it executable, and then add the URL as a calendar subscription from within Google Calendar.

<?php

// create a new curl resource and set options

$ch = curl_init();
 
curl_setopt($ch, CURLOPT_URL, "https://icloud.com/calendar/url");
 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
 
// grab URL, and return output
 
$output = curl_exec($ch);
 
// Send the header based on the response from the server
 
header('Content-type: text/calendar');
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Sat, 5 Sep 1994 05:00:00 GMT"); // Date in the paste
 
// Send the curl output
 
if (empty($output))    
    echo var_dump($output);
else
    echo $output;
 
?>

Until next time – GEEK OUT!

~GT~

2 thoughts on “Adding iCloud Calendar Subscriptions to Google Calendar”

  1. I tried this (or at least a variation of this), but Google responds with “Settings Error–Could not fetch the url” when I try to subscribe to the calendar file. It works perfect in Outlook. Any ideas?

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload the CAPTCHA.