Freebusy: query

返回一组日历的有空/忙碌信息。 立即尝试

请求

HTTP 请求

POST https://www.googleapis.com/calendar/v3/freeBusy

授权

此请求至少授予以下其中一个范围的授权:

范围
https://www.googleapis.com/auth/calendar.readonly
https://www.googleapis.com/auth/calendar

如需了解详情,请参阅身份验证和授权页面。

请求正文

在请求正文中,请按以下结构提供数据:

{
  "timeMin": datetime,
  "timeMax": datetime,
  "timeZone": string,
  "groupExpansionMax": integer,
  "calendarExpansionMax": integer,
  "items": [
    {
      "id": string
    }
  ]
}
属性名称 说明 备注
timeMin datetime 查询间隔的开始时间,格式遵循 RFC3339
timeMax datetime 按照 RFC3339 格式查询间隔的结束时间。
timeZone string 响应中使用的时区。(可选)默认值为世界协调时间 (UTC)。
groupExpansionMax integer 为单个群组提供的日历标识符数量上限。(可选)如果成员数超过此值,系统会返回错误。最大值为 100。
calendarExpansionMax integer 可提供 FreeBusy 信息的日历数量上限。(可选)最大值为 50。
items[] list 要查询的日历和/或群组列表。
items[].id string 日历或群组的标识符。

响应

如果成功,此方法将返回采用以下结构的响应正文:

{
  "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
        }
      ]
    }
  }
}
属性名称 说明 备注
kind string 资源的类型(“calendar#freeBusy”)。
timeMin datetime 间隔的开始时间。
timeMax datetime 间隔的结束。
groups object 群组扩展。
groups.(key) nested object 属于此群组的日历列表。
groups.(key).errors[] list 可选错误(如果组计算失败)。
groups.(key).errors[].domain string 错误的域或广泛类别。
groups.(key).errors[].reason string 出错的具体原因。部分可能的值包括:
  • groupTooBig”- 所请求的用户群组对于单个查询而言过大。
  • tooManyCalendarsRequested”- 所请求的日历数量对于单个查询而言过大。
  • notFound”- 找不到请求的资源。
  • internalError”- API 服务遇到了内部错误。
未来可能会添加其他错误类型,因此客户端应妥善处理未包含在此列表中的其他错误状态。
groups.(key).calendars[] list 群组中的日历标识符列表。
calendars object 日历的有空/忙碌信息列表。
calendars.(key) nested object 单个日历的有空/忙碌状态扩展。
calendars.(key).errors[] list 可选错误(如果日历计算失败)。
calendars.(key).errors[].domain string 错误的域或广泛类别。
calendars.(key).errors[].reason string 出错的具体原因。部分可能的值包括:
  • groupTooBig”- 所请求的用户群组对于单个查询而言过大。
  • tooManyCalendarsRequested”- 所请求的日历数量对于单个查询而言过大。
  • notFound”- 找不到请求的资源。
  • internalError”- API 服务遇到了内部错误。
未来可能会添加其他错误类型,因此客户端应妥善处理未包含在此列表中的其他错误状态。
calendars.(key).busy[] list 此日历应视为忙碌的时间范围列表。
calendars.(key).busy[].start datetime 时间段的开始时间(含)。
calendars.(key).busy[].end datetime 相应时间段(不含)的结束时间。

试试看!

请使用下面的 API Explorer 针对实际数据调用此方法,然后查看响应。