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

Is it possible to query events from external calendar?

我能够列出默认 google 日历中的事件,但是当我尝试列出其他日历中的事件时,出现错误:

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

我不知道是否不支持外部日历,或者我得到的这些外部日历的 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;
  }
}

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

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

请注意:

如果您正在获取事件列表,您应该尝试使用 Events: list

希望这些信息对您有所帮助。