Colors: get
Returns the color definitions for calendars and events. Try it now or see an example. カレンダーとイベントの色の定義を返します。今すぐ試すか、例を見てください。
Request要求
HTTP requestHTTPリクエスト
GET https://www.googleapis.com/calendar/v3/colors
Request bodyリクエストボディ
Do not supply a request body with this method.このメソッドでリクエストボディを指定しないでください。
Response応答
If successful, this method returns a Colors resource in the response body.成功した場合、このメソッドはレスポンス本文にColorsリソースを返します。
Examples例
Note: The code examples available for this method do not represent all supported programming languages (see the client libraries page for a list of supported languages).注:このメソッドで使用可能なコード例は、サポートされているすべてのプログラミング言語を表しているわけではありません(サポートされている言語のリストについては、クライアントライブラリのページを参照してください)。
Java
Uses the Java client library.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
Uses the Python client library.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']
PHP
Uses the PHP client library.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ルビー
Uses the Ruby client library.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。ネット
Uses the .NET client library..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);
}
Try it!それを試してみてください!
Use the APIs Explorer below to call this method on live data and see the response. 以下のAPI Explorerを使用して、ライブデータに対してこのメ??ソッドを呼び出して応答を確認してください。
スポンサーリンク





