1
1

[Google Calendar API(V3)] Javaでカレンダーとイベントの色を取得する

Posted at

Google Calendar API V3(Java)を使用して、
Googleカレンダーのカレンダーとイベントの色を取得する
についてご紹介します。

下記の色を取得できます。
・カレンダーに指定できる色

・イベントに指定できる色

APIを利用する環境の準備から始める場合や、コードを実行する際は、
⧉[Google Calendar API(V3)] JavaでCalendar APIを使う
を参照ください。

No 目次
1 色を取得
1 スコープ
2 実行
3 レスポンスの内容

1. 色を取得

Googleカレンダーのカレンダーとイベントの色を取得します。

1.1. スコープ

このAPIを実行するには、以下のいずれかのスコープを指定してください。

CalendarScopes.CALENDAR
CalendarScopes.CALENDAR_READONLY

⧉[Google Calendar API(V3)] JavaでCalendar APIを使う(2.2 Driveインスタンスを取得)
でスコープを指定してください。

1.2. 実行

public static void main(String[] args) throws Exception{
    Calendar calendar = getCalendar();
    
    Calendar.Colors colors = calendar.colors();
    Calendar.Colors.Get get = colors.get();
    
    Colors res = get.execute();
    System.out.println(res);
}

1.2.1. HTTPリクエスト

GET: https://www.googleapis.com/calendar/v3/colors
が実行されます。

1.2.2. クエリパラメータ

クエリパラメータはありません。

1.3. レスポンスの内容

Colors

メソッド 戻り値 説明
getKind String リソースの種類
固定文字列:"calendar#colors"
getUpdated DateTime カラーパレットの最終更新日時
getCalendar Map カレンダーの色を表すグローバルパレット
getEvent Map イベントの色を表すグローバルパレット

ColorDefinition

メソッド 戻り値 説明
foreground String 前景色
background String 背景色


おしまい。。
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1