我已经为此奋斗了一段时间,终于让它工作了。这不是很好的包装,但这是我正在寻找的答案
首先,您必须获取日历 ID。如果您进入日历并单击名称旁边的向下箭头图标,您将看到日历设置选项。选择该菜单项。在底部附近,您将看到日历地址。需要一点时间才能找到日历 ID,它看起来像这样
(日历 ID:o4g3921hdiaq5p8kdat2l4vgis@group.calendar.google.com)
你想要 o4g39j1hdihq4p8kdat2l4vgis@group.calendar.google.com
以后我会想在 php 中得到它,但现在我可以硬编码。所以我为此设置了一个变量
$calendar_user = 'o4g39j1hdihq4p8kdat2l4vgis@group.calendar.google.com';
检索事件时,您将像这样设置用户
$gdataCal = new Zend_Gdata_Calendar($client);
$query = $gdataCal->newEventQuery();
$query->setUser($calendar_user);
但是,当您添加事件时,您不能这样做,您必须在插入事件的位置使用 $calendar_user。
所以这里是完整的代码
$calendar_user = 'o4g39j1hdihq4p8kdat2l4vgis@group.calendar.google.com';
$user = 'myemail@yahoo.com';
$pass = 'mygooglecalendarpassword';
$service = Zend_Gdata_Calendar::AUTH_SERVICE_NAME; // predefined service name for calendar
$client = Zend_Gdata_ClientLogin::getHttpClient($user,$pass,$service);
$gc = new Zend_Gdata_Calendar($client);
$newEntry = $gc->newEventEntry();
$newEntry->title = $gc->newTitle("mytitle");
$newEntry->where = array($gc->newWhere("meeting place"));
$newEntry->content = $gc->newContent("Meeting description");
$newEntry->content->type = 'text';
$when = $gc->newWhen();
$when->startTime = "{'2012-06-28'}T{'10:00'}:00.000{'-08'}:00";
$when->endTime = "{'2012-06-28'}T{'11:00'}:00.000{'-08'}:00";
$newEntry->when = array($when);
$createdEvent = $gc->insertEvent($newEntry, "http://www.google.com/calendar/feeds/".$calendar_user."/private/full");
现在我希望这会有所帮助。我告诉你我花了很长时间才弄清楚这一点,但我不是世界上最聪明的人。