Colors: get

캘린더 및 일정의 색상 정의를 반환합니다. 지금 사용해 보기 또는 예시를 확인하세요.

요청

HTTP 요청

GET https://www.googleapis.com/calendar/v3/colors

승인

이 요청은 다음 범위 중 하나 이상을 사용하여 승인을 허용합니다.

범위
https://www.googleapis.com/auth/calendar
https://www.googleapis.com/auth/calendar.readonly

자세한 내용은 인증 및 승인 페이지를 참고하세요.

요청 본문

이 메소드를 사용할 때는 요청 본문을 제공하지 마세요.

응답

요청에 성공할 경우 이 메서드는 응답 본문에 Colors 리소스를 반환합니다.

참고: 이 메서드에 제공되는 코드 예시가 지원되는 모든 프로그래밍 언어를 나타내는 것은 아닙니다. 지원되는 언어 목록은 클라이언트 라이브러리 페이지를 참조하세요.

Java

자바 클라이언트 라이브러리를 사용합니다.

import com.google.api.services.calendar.Calendar;
import com.google.api.services.calendar.model.Colors;
import com.google.api.services.calendar.model.ColorDefinition;

import java.util.Map;
// ...

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

// Retrieve color definitions for calendars and events
Colors colors = service.colors().get().execute();

// Print available calendar list entry colors
for (Map.Entry<String, ColorDefinition> color : colors.getCalendar().entrySet()) {
  System.out.println("ColorId : " + color.getKey());
  System.out.println("  Background: " + color.getValue().getBackground());
  System.out.println("  Foreground: " + color.getValue().getForeground());
}

// Print available event colors
for (Map.Entry<String, ColorDefinition> color : colors.getEvent().entrySet()) {
  System.out.println("ColorId : " + color.getKey());
  System.out.println("  Background: " + color.getValue().getBackground());
  System.out.println("  Foreground: " + color.getValue().getForeground());
}

Python

Python 클라이언트 라이브러리를 사용합니다.

colors = service.colors().get().execute()

# Print available calendarListEntry colors.
for id, color in colors['calendar'].iteritem():
  print 'colorId: %s' % id
  print '  Background: %s' % color['background']
  print '  Foreground: %s' % color['foreground']
# Print available event colors.
for id, color in colors['event'].iteritem():
  print 'colorId: %s' % id
  print '  Background: %s' % color['background']
  print '  Foreground: %s' % color['foreground']

2,399필리핀

PHP 클라이언트 라이브러리를 사용합니다.

$colors = $service->colors->get();

// Print available calendarListEntry colors.
foreach ($colors->getCalendar() as $key => $color) {
  print "colorId : {$key}\n";
  print "  Background: {$color->getBackground()}\n";
  print "  Foreground: {$color->getForeground()}\n";
}
// Print available event colors.
foreach ($colors->getEvent() as $key => $color) {
  print "colorId : {$key}\n";
  print "  Background: {$color->getBackground()}\n";
  print "  Foreground: {$color->getForeground()}\n";
}

Ruby

Ruby 클라이언트 라이브러리 사용

result = client.get_color()

# Print available calendarListEntry colors.
result.calendar.keys.each do |key|
  print "colorId: #{key}\n"
  print "  Background: #{result.calendar[key].background}\n"
  print "  Foreground: #{result.calendar[key].foreground}\n"
end

# Print available event colors.
result.event.keys.each do |key|
  print "colorId: #{key}\n"
  print "  Background: #{result.event[key].background}\n"
  print "  Foreground: #{result.event[key].foreground}\n"
end

.NET

.NET 클라이언트 라이브러리를 사용합니다.

Colors colors = service.Colors.Get().Fetch();

// Print available calendarListEntry colors.
foreach (KeyValuePair<String, ColorDefinition> color in colors.Calendar) {
  System.out.println("ColorId : " + color.Key);
  System.out.println("  Background: " + color.Value.Background);
  System.out.println("  Foreground: " + color.Value.Foreground);
}
// Print available event colors.
foreach (KeyValuePair<String, ColorDefinition> color in colors.Event) {
  System.out.println("ColorId : " + color.Key);
  System.out.println("  Background: " + color.Value.Background);
  System.out.println("  Foreground: " + color.Value.Foreground);
}

사용해 보기

아래의 API 탐색기를 사용하여 실시간 데이터를 대상으로 이 메소드를 호출하고 응답을 확인해 보세요.