是否可以从外部日历查询事件?

时间:2017-01-26 23:33:29

标签: php google-api google-calendar-api

我能够列出默认谷歌日历中的事件,但是当我尝试列出其他日历中的事件时,我收到了错误:

PHP Fatal error:  Uncaught exception 'Google_Service_Exception' with message '{
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "notFound",
    "message": "Not Found"
   }
  ],
  "code": 404,
  "message": "Not Found"
 }
}

我不知道外部日历是否不受支持,或者我得到了这些外部cals的错误ID。我使用此方法CalendarList: list查询我帐户中的所有可用日历,但只有第一个可用(我的默认设置)。我不确定这是否是获取ID的正确方法:

$calendarList = $service->calendarList->listCalendarList();

while(true) {
  foreach ($calendarList->getItems() as $calendarListEntry) {
    echo $calendarListEntry->getSummary();
    echo "\r\n";
  }
  $pageToken = $calendarList->getNextPageToken();
  if ($pageToken) {
    $optParams = array('pageToken' => $pageToken);
    $calendarList = $service->calendarList->listCalendarList($optParams);
  } else {
    break;
  }
}

1 个答案:

答案 0 :(得分:2)

我创建了一个测试方案:CalendarList: get一封电子邮件,但没有正确地将日历共享给有权调用该功能的日历。

enter image description here

然后,我与发出API请求的用户分享了日历:

enter image description here

请注意:

enter image description here

如果要确定事件列表,则应尝试使用Events: list

希望这些信息有所帮助。