views:

34

answers:

0

I'm trying to get an ical feed working with Google Calendar and I just can't seem to get it right. I'm using the PHP iCalcreator class (http://www.kigkonsult.se/iCalcreator/index.php) and here's the code I'm using:

<?php

require_once APP_ROOT . '/lib/icalcreator.class.php';

$user = new User;
$user->Get(1);

$v = new vcalendar(); // create a new calendar instance
$v->setConfig('unique_id', 'Domain ' . $user->id); // set Your unique id
$v->setProperty('method', 'PUBLISH'); // required of some calendar software
$v->setProperty('X-WR-CALNAME;VALUE=TEXT', 'My Calendar');
$v->setProperty('X-WR-CALDESC', 'The description');

$tasks = $user->GetTasks();

foreach ($tasks as $task) {

    $vevent = new vevent(); // create an event calendar component
    $year = date('Y', strtotime($task->due));
    $month = date('m', strtotime($task->due));
    $day = date('d', strtotime($task->due));
    $hour = date('H', strtotime($task->due));
    $min = date('i', strtotime($task->due));
    $sec = date('s', strtotime($task->due));

    $vevent = new vevent();
    $vevent->setProperty('dtstart', array('year'=> $year, 'month'=> $month, 'day'=> $day, 'hour'=> $hour, 'min'=> $min, 'sec'=> $sec));
    $vevent->setProperty('dtend', array('year'=> $year, 'month'=> $month, 'day'=> $day, 'hour'=> $hour, 'min'=> $min, 'sec'=> $sec));
    $vevent->setProperty('summary', $task->subject);
    $vevent->setProperty('description', "Description of the task");
    $v->setComponent($vevent);
}

$v->returnCalendar();

?>

The problem is, the summary and description for the calendar don't come through, and the description for each event doesn't come through.

Any idea what's going on?