CalendarList: get

从用户的日历列表中返回日历。 立即试用查看示例

请求

HTTP 请求

GET https://www.googleapis.com/calendar/v3/users/me/calendarList/calendarId

参数

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

授权

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

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

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

请求正文

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

响应

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

示例

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

Java

使用 Java 客户端库

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

// ...

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

// Retrieve a specific calendar list entry
CalendarListEntry calendarListEntry = service.calendarList().get("calendarId").execute();

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

Python

使用 Python 客户端库

calendar_list_entry = service.calendarList().get(calendarId='calendarId').execute()

print(calendar_list_entry['summary'])

PHP

使用 PHP 客户端库

$calendarListEntry = $service->calendarList->get('calendarId');

echo $calendarListEntry->getSummary();

Ruby

使用 Ruby 客户端库

result = client.get_calendar_list('calendarId')
print result.summary

试试看!

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