我想使用 google api v3 freebusy (php) 来查找我的三个日历的免费 freebusy 信息,但我没有找到我的代码的正确结尾。我想访问 $freebusy-response 的“日历 - 忙碌”值。
由于 api-reference 中没有示例代码,而且我在网络上找不到任何工作代码(但很多人要求它),所以你们是我运行它的最后希望。
...
$service = new Google_CalendarService($client); // successfully connected
$freebusy = new Google_FreeBusyRequest();
$freebusy->setTimeMin('2013-07-08T08:00:00.000-07:00');
$freebusy->setTimeMax('2013-07-08T10:00:00.000-07:00');
$freebusy->setTimeZone('Europe/Berlin');
$freebusy->setGroupExpansionMax(10);
$freebusy->setCalendarExpansionMax(10);
$mycalendars= array("my_calendar_id1@developer.gserviceaccount.com","my_calendar_id2@group.calendar.google.com","my_calendar_id3@group.calendar.google.com");
$freebusy->setItems = $mycalendars;
$createdReq = $service->freebusy->query($freebusy);
echo $createdReq->getKind(); // works
echo $createdReq->getTimeMin(); // works
echo $createdReq->getTimeMax(); // works
$s = $createdReq->getCalendars($diekalender);
Print_r($s, true); // doesn't show anything
// needed: the value of "calendars": { (key): { "busy" - array of one or all calendars
这就是 API 参考关于响应的内容:
{
"kind": "calendar#freeBusy",
"timeMin": datetime,
"timeMax": datetime,
"groups": {
(key): {
"errors": [
{
"domain": string,
"reason": string
}
],
"calendars": [
string
]
}
},
"calendars": {
(key): {
"errors": [
{
"domain": string,
"reason": string
}
],
"busy": [
{
"start": datetime,
"end": datetime
}
]
}
}
}