1
我正在嘗試使用Google日曆獲取ical feed,但我似乎無法正確理解。我使用PHP iCalcreator類(http://www.kigkonsult.se/iCalcreator/index.php),這裏是我使用的代碼:PHP/ICAL/Google日曆
<?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();
?>
的問題是,總結和說明日曆不來通過,以及每個事件的說明不通過。
任何想法是怎麼回事?