อัปเดตข้อมูลเมตาสําหรับปฏิทิน ลองใช้เลยหรือดูตัวอย่าง
ส่งคำขอ
คำขอ HTTP
PUT https://www.googleapis.com/calendar/v3/calendars/calendarId
พารามิเตอร์
ชื่อพารามิเตอร์ | ค่า | คำอธิบาย |
---|---|---|
พารามิเตอร์เส้นทาง | ||
calendarId |
string |
ตัวระบุปฏิทิน หากต้องการเรียกรหัสปฏิทิน ให้เรียกใช้เมธอด calendarList.list หากต้องการเข้าถึงปฏิทินหลักของผู้ใช้ที่เข้าสู่ระบบอยู่ ให้ใช้คีย์เวิร์ด "primary "
|
การให้สิทธิ์
คําขอนี้ต้องได้รับอนุญาตจากขอบเขตต่อไปนี้
ขอบเขต |
---|
https://www.googleapis.com/auth/calendar |
สําหรับข้อมูลเพิ่มเติม โปรดดูหน้าการตรวจสอบสิทธิ์และการให้สิทธิ์
เนื้อหาของคำขอ
ในเนื้อหาคําขอ ให้ระบุทรัพยากรในปฏิทินด้วยพร็อพเพอร์ตี้ต่อไปนี้
ชื่อพร็อพเพอร์ตี้ | ค่า | คำอธิบาย | หมายเหตุ |
---|---|---|---|
พร็อพเพอร์ตี้ที่ไม่บังคับ | |||
description |
string |
คําอธิบายปฏิทิน ไม่บังคับ | เขียนได้ |
location |
string |
สถานที่ตั้งทางภูมิศาสตร์ของปฏิทินในรูปแบบรูปแบบอิสระ ไม่บังคับ | เขียนได้ |
summary |
string |
ชื่อปฏิทิน | เขียนได้ |
timeZone |
string |
เขตเวลาของปฏิทิน (จัดรูปแบบเป็นชื่อฐานข้อมูลเขตเวลา IANA เช่น "ยุโรป/ซูริค") ไม่บังคับ | เขียนได้ |
คำตอบ
หากสําเร็จ วิธีนี้จะแสดงทรัพยากรในปฏิทินในส่วนการตอบกลับ
ตัวอย่าง
หมายเหตุ: ตัวอย่างโค้ดที่มีสำหรับวิธีการนี้ไม่ได้แสดงถึงภาษาโปรแกรมที่รองรับทั้งหมด (ดูรายการภาษาที่รองรับได้ในหน้าไลบรารีของไคลเอ็นต์)
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
# 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
// 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
calendar = client.get_calendar('primary') calendar.summary = "New Summary" result = client.update_calendar(calendar.id, calendar) print result.etag
ลองใช้เลย
ใช้เครื่องมือสํารวจ API ด้านล่างเพื่อเรียกใช้วิธีการนี้สําหรับข้อมูลสดและดูการตอบกลับ