I am looking for specifics in creating an iCal feed, for use in applications such as Google Calendar and on peoples phones.
I currently have a script using the iCalendar class that when the url is visited, an ics file is created and sent to the browser:
function returnCalendar() {
$filename = $this->getConfig( 'filename' );
$output = $this->createCalendar();
$filesize = strlen( $output );
if( 'xcal' == $this->format )
header( 'Content-Type: application/calendar+xml; charset=utf-8' );
else
header( 'Content-Type: text/calendar; charset=utf-8' );
header( 'Content-Length: '.$filesize );
header( 'Content-Disposition: attachment; filename="'.$filename.'"' );
header( 'Cache-Control: max-age=10' );
echo $output;
die();
}
I would like (as I previously mentioned) to create a feed (a unique url per user), and was wondering about the techicalities of this? I was thinking I would need a cronjob to just generate a calandar for everyone and then link users to this feed, however this seems very inefficient if say only one user is using the feed.
Would it be possible to set the script to only run when someone requested a calandar and then send them the appropriate one back?
Does anyone know how often Google Calandar etc updates, how it works and how I can test it?
Many thanks for your time,
I would use the iCal calandar class for PHP, then link the users to a PHP file which does live generation (possibly with some sort of half an hour cache system to stop it being bombarded).
Using a cronjob for generation of data would be kind of heavy on the cpu usage!