Calendars: update

อัปเดตข้อมูลเมตาสำหรับปฏิทิน ลองใช้เลยหรือดูตัวอย่าง

ส่งคำขอ

คำขอ HTTP

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

พารามิเตอร์

ชื่อพารามิเตอร์ ค่า คำอธิบาย
พารามิเตอร์เส้นทาง
calendarId string ตัวระบุปฏิทิน หากต้องการเรียกข้อมูลรหัสปฏิทิน ให้เรียกเมธอด calendarList.list หากต้องการเข้าถึงปฏิทินหลักของผู้ใช้ที่เข้าสู่ระบบในปัจจุบัน ให้ใช้คีย์เวิร์ด "primary"

การให้สิทธิ์

คำขอนี้ต้องได้รับสิทธิ์ด้วยขอบเขตต่อไปนี้

ขอบเขต
https://www.googleapis.com/auth/calendar

โปรดดูข้อมูลเพิ่มเติมที่หน้าการตรวจสอบสิทธิ์และการให้สิทธิ์

เนื้อหาของคำขอ

ในส่วนเนื้อหาของคำขอ ให้ระบุทรัพยากรปฏิทินพร้อมด้วยพร็อพเพอร์ตี้ต่อไปนี้

ชื่อพร็อพเพอร์ตี้ ค่า คำอธิบาย Notes
พร็อพเพอร์ตี้ที่ไม่บังคับ
description string คำอธิบายของปฏิทิน ไม่บังคับ เขียนได้
location string สถานที่ตั้งทางภูมิศาสตร์ของปฏิทินเป็นข้อความรูปแบบอิสระ ไม่บังคับ เขียนได้
summary string ชื่อปฏิทิน เขียนได้
timeZone string เขตเวลาของปฏิทิน (จัดรูปแบบเป็นชื่อฐานข้อมูลเขตเวลา IANA เช่น "ยุโรป/ซูริค") ไม่บังคับ เขียนได้

คำตอบ

หากสำเร็จ เมธอดนี้จะแสดงผลทรัพยากรปฏิทินในเนื้อหาการตอบสนอง

ตัวอย่าง

หมายเหตุ: ตัวอย่างโค้ดที่มีสำหรับวิธีการนี้ไม่ได้แสดงถึงภาษาโปรแกรมที่รองรับทั้งหมด (ดูรายการภาษาที่รองรับได้ในหน้าไลบรารีของไคลเอ็นต์)

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 a calendar
com.google.api.services.calendar.model.Calendar calendar =
    service.calendars().get('primary').execute();

// Make a change
calendar.setSummary("calendarSummary");

// Update the altered calendar
com.google.api.services.calendar.model.Calendar updatedCalendar =
    service.calendars().update(calendar.getId(), calendar).execute();

System.out.println(updatedCalendar.getEtag());

Python

ใช้ไลบรารีของไคลเอ็นต์ Python

# First retrieve the calendar from the API.
calendar = service.calendars().get(calendarId='primary').execute()

calendar['summary'] = 'New Summary'

updated_calendar = service.calendars().update(calendarId=calendar['id'], body=calendar).execute()

print updated_calendar['etag']

PHP

ใช้ไลบรารีของไคลเอ็นต์ PHP

// First retrieve the calendar from the API.
$calendar = $service->calendars->get('primary');

$calendar->setSummary('New Summary');

$updatedCalendar = $service->calendars->update('primary', $calendar);

echo $updatedCalendar->getEtag();

Ruby

ใช้ไลบรารีของไคลเอ็นต์ Ruby

calendar = client.get_calendar('primary')
calendar.summary = "New Summary"
result = client.update_calendar(calendar.id, calendar)
print result.etag

ลองใช้เลย

ใช้ API Explorer ด้านล่างเพื่อเรียกใช้เมธอดนี้กับข้อมูลแบบเรียลไทม์และดูการตอบสนอง