Unicode C Google Calendar: Get Color Definitions

Back to Index

Returns the color definitions for calendars and events.

Documentation: https://developers.google.com/google-apps/calendar/v3/reference/colors/get


#include <C_CkRestW.h>
#include <C_CkOAuth2W.h>
#include <C_CkStringBuilderW.h>
#include <C_CkJsonObjectW.h>

void ChilkatSample(void)
    {
    HCkRestW rest;
    BOOL success;
    HCkOAuth2W oauth2;
    HCkStringBuilderW sbJson;
    HCkJsonObjectW json;
    const wchar_t *kind;
    const wchar_t *updated;
    const wchar_t *calendar1Background;
    const wchar_t *calendar1Foreground;
    const wchar_t *calendar2Background;
    const wchar_t *calendar2Foreground;
    const wchar_t *calendar3Background;
    const wchar_t *calendar3Foreground;
    const wchar_t *calendar4Background;
    const wchar_t *calendar4Foreground;
    const wchar_t *calendar5Background;
    const wchar_t *calendar5Foreground;
    const wchar_t *calendar6Background;
    const wchar_t *calendar6Foreground;
    const wchar_t *calendar7Background;
    const wchar_t *calendar7Foreground;
    const wchar_t *calendar8Background;
    const wchar_t *calendar8Foreground;
    const wchar_t *calendar9Background;
    const wchar_t *calendar9Foreground;
    const wchar_t *calendar10Background;
    const wchar_t *calendar10Foreground;
    const wchar_t *calendar11Background;
    const wchar_t *calendar11Foreground;
    const wchar_t *calendar12Background;
    const wchar_t *calendar12Foreground;
    const wchar_t *calendar13Background;
    const wchar_t *calendar13Foreground;
    const wchar_t *calendar14Background;
    const wchar_t *calendar14Foreground;
    const wchar_t *calendar15Background;
    const wchar_t *calendar15Foreground;
    const wchar_t *calendar16Background;
    const wchar_t *calendar16Foreground;
    const wchar_t *calendar17Background;
    const wchar_t *calendar17Foreground;
    const wchar_t *calendar18Background;
    const wchar_t *calendar18Foreground;
    const wchar_t *calendar19Background;
    const wchar_t *calendar19Foreground;
    const wchar_t *calendar20Background;
    const wchar_t *calendar20Foreground;
    const wchar_t *calendar21Background;
    const wchar_t *calendar21Foreground;
    const wchar_t *calendar22Background;
    const wchar_t *calendar22Foreground;
    const wchar_t *calendar23Background;
    const wchar_t *calendar23Foreground;
    const wchar_t *calendar24Background;
    const wchar_t *calendar24Foreground;
    const wchar_t *event1Background;
    const wchar_t *event1Foreground;
    const wchar_t *event2Background;
    const wchar_t *event2Foreground;
    const wchar_t *event3Background;
    const wchar_t *event3Foreground;
    const wchar_t *event4Background;
    const wchar_t *event4Foreground;
    const wchar_t *event5Background;
    const wchar_t *event5Foreground;
    const wchar_t *event6Background;
    const wchar_t *event6Foreground;
    const wchar_t *event7Background;
    const wchar_t *event7Foreground;
    const wchar_t *event8Background;
    const wchar_t *event8Foreground;
    const wchar_t *event9Background;
    const wchar_t *event9Foreground;
    const wchar_t *event10Background;
    const wchar_t *event10Foreground;
    const wchar_t *event11Background;
    const wchar_t *event11Foreground;

    rest = CkRestW_Create();

    //   Provide a previously obtained OAuth2 access token.
    oauth2 = CkOAuth2W_Create();
    CkOAuth2W_putAccessToken(oauth2,L"OAUTH2_ACCESS_TOKEN");
    CkRestW_SetAuthOAuth2(rest,oauth2);

    success = CkRestW_Connect(rest,L"www.googleapis.com",443,TRUE,TRUE);
    if (success != TRUE) {
        wprintf(L"%s\n",CkRestW_lastErrorText(rest));
        CkRestW_Dispose(rest);
        CkOAuth2W_Dispose(oauth2);
        return;
    }

    sbJson = CkStringBuilderW_Create();
    success = CkRestW_FullRequestNoBodySb(rest,L"GET",L"/calendar/v3/colors",sbJson);
    if (success != TRUE) {
        wprintf(L"%s\n",CkRestW_lastErrorText(rest));
        CkRestW_Dispose(rest);
        CkOAuth2W_Dispose(oauth2);
        CkStringBuilderW_Dispose(sbJson);
        return;
    }

    if (CkRestW_getResponseStatusCode(rest) != 200) {
        wprintf(L"Received error response code: %d\n",CkRestW_getResponseStatusCode(rest));
        wprintf(L"Response body:\n");
        wprintf(L"%s\n",CkStringBuilderW_getAsString(sbJson));
        CkRestW_Dispose(rest);
        CkOAuth2W_Dispose(oauth2);
        CkStringBuilderW_Dispose(sbJson);
        return;
    }

    json = CkJsonObjectW_Create();
    CkJsonObjectW_LoadSb(json,sbJson);

    //  The following code parses the JSON response.
    //  A sample JSON response is shown below the sample code.

    kind = CkJsonObjectW_stringOf(json,L"kind");
    updated = CkJsonObjectW_stringOf(json,L"updated");
    calendar1Background = CkJsonObjectW_stringOf(json,L"calendar.1.background");
    calendar1Foreground = CkJsonObjectW_stringOf(json,L"calendar.1.foreground");
    calendar2Background = CkJsonObjectW_stringOf(json,L"calendar.2.background");
    calendar2Foreground = CkJsonObjectW_stringOf(json,L"calendar.2.foreground");
    calendar3Background = CkJsonObjectW_stringOf(json,L"calendar.3.background");
    calendar3Foreground = CkJsonObjectW_stringOf(json,L"calendar.3.foreground");
    calendar4Background = CkJsonObjectW_stringOf(json,L"calendar.4.background");
    calendar4Foreground = CkJsonObjectW_stringOf(json,L"calendar.4.foreground");
    calendar5Background = CkJsonObjectW_stringOf(json,L"calendar.5.background");
    calendar5Foreground = CkJsonObjectW_stringOf(json,L"calendar.5.foreground");
    calendar6Background = CkJsonObjectW_stringOf(json,L"calendar.6.background");
    calendar6Foreground = CkJsonObjectW_stringOf(json,L"calendar.6.foreground");
    calendar7Background = CkJsonObjectW_stringOf(json,L"calendar.7.background");
    calendar7Foreground = CkJsonObjectW_stringOf(json,L"calendar.7.foreground");
    calendar8Background = CkJsonObjectW_stringOf(json,L"calendar.8.background");
    calendar8Foreground = CkJsonObjectW_stringOf(json,L"calendar.8.foreground");
    calendar9Background = CkJsonObjectW_stringOf(json,L"calendar.9.background");
    calendar9Foreground = CkJsonObjectW_stringOf(json,L"calendar.9.foreground");
    calendar10Background = CkJsonObjectW_stringOf(json,L"calendar.10.background");
    calendar10Foreground = CkJsonObjectW_stringOf(json,L"calendar.10.foreground");
    calendar11Background = CkJsonObjectW_stringOf(json,L"calendar.11.background");
    calendar11Foreground = CkJsonObjectW_stringOf(json,L"calendar.11.foreground");
    calendar12Background = CkJsonObjectW_stringOf(json,L"calendar.12.background");
    calendar12Foreground = CkJsonObjectW_stringOf(json,L"calendar.12.foreground");
    calendar13Background = CkJsonObjectW_stringOf(json,L"calendar.13.background");
    calendar13Foreground = CkJsonObjectW_stringOf(json,L"calendar.13.foreground");
    calendar14Background = CkJsonObjectW_stringOf(json,L"calendar.14.background");
    calendar14Foreground = CkJsonObjectW_stringOf(json,L"calendar.14.foreground");
    calendar15Background = CkJsonObjectW_stringOf(json,L"calendar.15.background");
    calendar15Foreground = CkJsonObjectW_stringOf(json,L"calendar.15.foreground");
    calendar16Background = CkJsonObjectW_stringOf(json,L"calendar.16.background");
    calendar16Foreground = CkJsonObjectW_stringOf(json,L"calendar.16.foreground");
    calendar17Background = CkJsonObjectW_stringOf(json,L"calendar.17.background");
    calendar17Foreground = CkJsonObjectW_stringOf(json,L"calendar.17.foreground");
    calendar18Background = CkJsonObjectW_stringOf(json,L"calendar.18.background");
    calendar18Foreground = CkJsonObjectW_stringOf(json,L"calendar.18.foreground");
    calendar19Background = CkJsonObjectW_stringOf(json,L"calendar.19.background");
    calendar19Foreground = CkJsonObjectW_stringOf(json,L"calendar.19.foreground");
    calendar20Background = CkJsonObjectW_stringOf(json,L"calendar.20.background");
    calendar20Foreground = CkJsonObjectW_stringOf(json,L"calendar.20.foreground");
    calendar21Background = CkJsonObjectW_stringOf(json,L"calendar.21.background");
    calendar21Foreground = CkJsonObjectW_stringOf(json,L"calendar.21.foreground");
    calendar22Background = CkJsonObjectW_stringOf(json,L"calendar.22.background");
    calendar22Foreground = CkJsonObjectW_stringOf(json,L"calendar.22.foreground");
    calendar23Background = CkJsonObjectW_stringOf(json,L"calendar.23.background");
    calendar23Foreground = CkJsonObjectW_stringOf(json,L"calendar.23.foreground");
    calendar24Background = CkJsonObjectW_stringOf(json,L"calendar.24.background");
    calendar24Foreground = CkJsonObjectW_stringOf(json,L"calendar.24.foreground");
    event1Background = CkJsonObjectW_stringOf(json,L"event.1.background");
    event1Foreground = CkJsonObjectW_stringOf(json,L"event.1.foreground");
    event2Background = CkJsonObjectW_stringOf(json,L"event.2.background");
    event2Foreground = CkJsonObjectW_stringOf(json,L"event.2.foreground");
    event3Background = CkJsonObjectW_stringOf(json,L"event.3.background");
    event3Foreground = CkJsonObjectW_stringOf(json,L"event.3.foreground");
    event4Background = CkJsonObjectW_stringOf(json,L"event.4.background");
    event4Foreground = CkJsonObjectW_stringOf(json,L"event.4.foreground");
    event5Background = CkJsonObjectW_stringOf(json,L"event.5.background");
    event5Foreground = CkJsonObjectW_stringOf(json,L"event.5.foreground");
    event6Background = CkJsonObjectW_stringOf(json,L"event.6.background");
    event6Foreground = CkJsonObjectW_stringOf(json,L"event.6.foreground");
    event7Background = CkJsonObjectW_stringOf(json,L"event.7.background");
    event7Foreground = CkJsonObjectW_stringOf(json,L"event.7.foreground");
    event8Background = CkJsonObjectW_stringOf(json,L"event.8.background");
    event8Foreground = CkJsonObjectW_stringOf(json,L"event.8.foreground");
    event9Background = CkJsonObjectW_stringOf(json,L"event.9.background");
    event9Foreground = CkJsonObjectW_stringOf(json,L"event.9.foreground");
    event10Background = CkJsonObjectW_stringOf(json,L"event.10.background");
    event10Foreground = CkJsonObjectW_stringOf(json,L"event.10.foreground");
    event11Background = CkJsonObjectW_stringOf(json,L"event.11.background");
    event11Foreground = CkJsonObjectW_stringOf(json,L"event.11.foreground");

    wprintf(L"Example Completed.\n");


    CkRestW_Dispose(rest);
    CkOAuth2W_Dispose(oauth2);
    CkStringBuilderW_Dispose(sbJson);
    CkJsonObjectW_Dispose(json);

    }

Sample JSON Response Body

{
  "kind": "calendar#colors",
  "updated": "2012-02-14T00:00:00.000Z",
  "calendar": {
    "1": {
      "background": "#ac725e",
      "foreground": "#1d1d1d"
    },
    "2": {
      "background": "#d06b64",
      "foreground": "#1d1d1d"
    },
    "3": {
      "background": "#f83a22",
      "foreground": "#1d1d1d"
    },
    "4": {
      "background": "#fa573c",
      "foreground": "#1d1d1d"
    },
    "5": {
      "background": "#ff7537",
      "foreground": "#1d1d1d"
    },
    "6": {
      "background": "#ffad46",
      "foreground": "#1d1d1d"
    },
    "7": {
      "background": "#42d692",
      "foreground": "#1d1d1d"
    },
    "8": {
      "background": "#16a765",
      "foreground": "#1d1d1d"
    },
    "9": {
      "background": "#7bd148",
      "foreground": "#1d1d1d"
    },
    "10": {
      "background": "#b3dc6c",
      "foreground": "#1d1d1d"
    },
    "11": {
      "background": "#fbe983",
      "foreground": "#1d1d1d"
    },
    "12": {
      "background": "#fad165",
      "foreground": "#1d1d1d"
    },
    "13": {
      "background": "#92e1c0",
      "foreground": "#1d1d1d"
    },
    "14": {
      "background": "#9fe1e7",
      "foreground": "#1d1d1d"
    },
    "15": {
      "background": "#9fc6e7",
      "foreground": "#1d1d1d"
    },
    "16": {
      "background": "#4986e7",
      "foreground": "#1d1d1d"
    },
    "17": {
      "background": "#9a9cff",
      "foreground": "#1d1d1d"
    },
    "18": {
      "background": "#b99aff",
      "foreground": "#1d1d1d"
    },
    "19": {
      "background": "#c2c2c2",
      "foreground": "#1d1d1d"
    },
    "20": {
      "background": "#cabdbf",
      "foreground": "#1d1d1d"
    },
    "21": {
      "background": "#cca6ac",
      "foreground": "#1d1d1d"
    },
    "22": {
      "background": "#f691b2",
      "foreground": "#1d1d1d"
    },
    "23": {
      "background": "#cd74e6",
      "foreground": "#1d1d1d"
    },
    "24": {
      "background": "#a47ae2",
      "foreground": "#1d1d1d"
    }
  },
  "event": {
    "1": {
      "background": "#a4bdfc",
      "foreground": "#1d1d1d"
    },
    "2": {
      "background": "#7ae7bf",
      "foreground": "#1d1d1d"
    },
    "3": {
      "background": "#dbadff",
      "foreground": "#1d1d1d"
    },
    "4": {
      "background": "#ff887c",
      "foreground": "#1d1d1d"
    },
    "5": {
      "background": "#fbd75b",
      "foreground": "#1d1d1d"
    },
    "6": {
      "background": "#ffb878",
      "foreground": "#1d1d1d"
    },
    "7": {
      "background": "#46d6db",
      "foreground": "#1d1d1d"
    },
    "8": {
      "background": "#e1e1e1",
      "foreground": "#1d1d1d"
    },
    "9": {
      "background": "#5484ed",
      "foreground": "#1d1d1d"
    },
    "10": {
      "background": "#51b749",
      "foreground": "#1d1d1d"
    },
    "11": {
      "background": "#dc2127",
      "foreground": "#1d1d1d"
    }
  }
}