Calendars: get

返回日历的元数据。立即试用查看示例

请求

HTTP 请求

GET https://www.googleapis.com/calendar/v3/calendars/calendarId

参数

参数名称 说明
路径参数
calendarId string 日历标识符。要检索日历 ID,请调用 calendarList.list 方法。如果您想访问当前登录的用户的主日历,请使用关键字“primary”。

授权

此请求需要获得以下至少一个范围的授权:

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

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

请求正文

使用此方法时请勿提供请求正文。

响应

如果成功,此方法将在响应正文中返回日历资源

示例

注意:此方法的代码示例并未列出所有受支持的编程语言(请参阅客户端库页面,查看受支持的语言列表)。

Java

使用 Java 客户端库

import com.google.api.services.calendar.Calendar;

// ...

// Initialize Calendar service with valid OAuth credentials
Calendar service = new Calendar.Builder(httpTransport, jsonFactory, credentials)
    .setApplicationName("applicationName").build();

// Retrieve the calendar
com.google.api.services.calendar.model.Calendar calendar =
    service.calendars().get('primary').execute();

System.out.println(calendar.getSummary());

Python

使用 Python 客户端库

calendar = service.calendars().get(calendarId='primary').execute()

print calendar['summary']

PHP

使用 PHP 客户端库

$calendar = $service->calendars->get('primary');

echo $calendar->getSummary();

Ruby

使用 Ruby 客户端库

result = client.get_calendar('primary')
print result.summary

试试看!

请使用下面的 API Explorer 对实时数据调用此方法并查看响应。