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 <CkRestW.h>
#include <CkOAuth2W.h>
#include <CkStringBuilderW.h>
#include <CkJsonObjectW.h>

void ChilkatSample(void)
    {
    CkRestW rest;
    bool success;

    //   Provide a previously obtained OAuth2 access token.
    CkOAuth2W oauth2;
    oauth2.put_AccessToken(L"OAUTH2_ACCESS_TOKEN");
    rest.SetAuthOAuth2(oauth2);

    success = rest.Connect(L"www.googleapis.com",443,true,true);
    if (success != true) {
        wprintf(L"%s\n",rest.lastErrorText());
        return;
    }

    CkStringBuilderW sbJson;
    success = rest.FullRequestNoBodySb(L"GET",L"/calendar/v3/colors",sbJson);
    if (success != true) {
        wprintf(L"%s\n",rest.lastErrorText());
        return;
    }

    if (rest.get_ResponseStatusCode() != 200) {
        wprintf(L"Received error response code: %d\n",rest.get_ResponseStatusCode());
        wprintf(L"Response body:\n");
        wprintf(L"%s\n",sbJson.getAsString());
        return;
    }

    CkJsonObjectW json;
    json.LoadSb(sbJson);

    //  The following code parses the JSON response.
    //  A sample JSON response is shown below the sample code.
    const wchar_t *kind = 0;
    const wchar_t *updated = 0;
    const wchar_t *calendar1Background = 0;
    const wchar_t *calendar1Foreground = 0;
    const wchar_t *calendar2Background = 0;
    const wchar_t *calendar2Foreground = 0;
    const wchar_t *calendar3Background = 0;
    const wchar_t *calendar3Foreground = 0;
    const wchar_t *calendar4Background = 0;
    const wchar_t *calendar4Foreground = 0;
    const wchar_t *calendar5Background = 0;
    const wchar_t *calendar5Foreground = 0;
    const wchar_t *calendar6Background = 0;
    const wchar_t *calendar6Foreground = 0;
    const wchar_t *calendar7Background = 0;
    const wchar_t *calendar7Foreground = 0;
    const wchar_t *calendar8Background = 0;
    const wchar_t *calendar8Foreground = 0;
    const wchar_t *calendar9Background = 0;
    const wchar_t *calendar9Foreground = 0;
    const wchar_t *calendar10Background = 0;
    const wchar_t *calendar10Foreground = 0;
    const wchar_t *calendar11Background = 0;
    const wchar_t *calendar11Foreground = 0;
    const wchar_t *calendar12Background = 0;
    const wchar_t *calendar12Foreground = 0;
    const wchar_t *calendar13Background = 0;
    const wchar_t *calendar13Foreground = 0;
    const wchar_t *calendar14Background = 0;
    const wchar_t *calendar14Foreground = 0;
    const wchar_t *calendar15Background = 0;
    const wchar_t *calendar15Foreground = 0;
    const wchar_t *calendar16Background = 0;
    const wchar_t *calendar16Foreground = 0;
    const wchar_t *calendar17Background = 0;
    const wchar_t *calendar17Foreground = 0;
    const wchar_t *calendar18Background = 0;
    const wchar_t *calendar18Foreground = 0;
    const wchar_t *calendar19Background = 0;
    const wchar_t *calendar19Foreground = 0;
    const wchar_t *calendar20Background = 0;
    const wchar_t *calendar20Foreground = 0;
    const wchar_t *calendar21Background = 0;
    const wchar_t *calendar21Foreground = 0;
    const wchar_t *calendar22Background = 0;
    const wchar_t *calendar22Foreground = 0;
    const wchar_t *calendar23Background = 0;
    const wchar_t *calendar23Foreground = 0;
    const wchar_t *calendar24Background = 0;
    const wchar_t *calendar24Foreground = 0;
    const wchar_t *event1Background = 0;
    const wchar_t *event1Foreground = 0;
    const wchar_t *event2Background = 0;
    const wchar_t *event2Foreground = 0;
    const wchar_t *event3Background = 0;
    const wchar_t *event3Foreground = 0;
    const wchar_t *event4Background = 0;
    const wchar_t *event4Foreground = 0;
    const wchar_t *event5Background = 0;
    const wchar_t *event5Foreground = 0;
    const wchar_t *event6Background = 0;
    const wchar_t *event6Foreground = 0;
    const wchar_t *event7Background = 0;
    const wchar_t *event7Foreground = 0;
    const wchar_t *event8Background = 0;
    const wchar_t *event8Foreground = 0;
    const wchar_t *event9Background = 0;
    const wchar_t *event9Foreground = 0;
    const wchar_t *event10Background = 0;
    const wchar_t *event10Foreground = 0;
    const wchar_t *event11Background = 0;
    const wchar_t *event11Foreground = 0;

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

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

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"
    }
  }
}