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_CkRest.h>
#include <C_CkOAuth2.h>
#include <C_CkStringBuilder.h>
#include <C_CkJsonObject.h>

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

    rest = CkRest_Create();

    //   Provide a previously obtained OAuth2 access token.
    oauth2 = CkOAuth2_Create();
    CkOAuth2_putAccessToken(oauth2,"OAUTH2_ACCESS_TOKEN");
    CkRest_SetAuthOAuth2(rest,oauth2);

    success = CkRest_Connect(rest,"www.googleapis.com",443,TRUE,TRUE);
    if (success != TRUE) {
        printf("%s\n",CkRest_lastErrorText(rest));
        CkRest_Dispose(rest);
        CkOAuth2_Dispose(oauth2);
        return;
    }

    sbJson = CkStringBuilder_Create();
    success = CkRest_FullRequestNoBodySb(rest,"GET","/calendar/v3/colors",sbJson);
    if (success != TRUE) {
        printf("%s\n",CkRest_lastErrorText(rest));
        CkRest_Dispose(rest);
        CkOAuth2_Dispose(oauth2);
        CkStringBuilder_Dispose(sbJson);
        return;
    }

    if (CkRest_getResponseStatusCode(rest) != 200) {
        printf("Received error response code: %d\n",CkRest_getResponseStatusCode(rest));
        printf("Response body:\n");
        printf("%s\n",CkStringBuilder_getAsString(sbJson));
        CkRest_Dispose(rest);
        CkOAuth2_Dispose(oauth2);
        CkStringBuilder_Dispose(sbJson);
        return;
    }

    json = CkJsonObject_Create();
    CkJsonObject_LoadSb(json,sbJson);

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

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

    printf("Example Completed.\n");


    CkRest_Dispose(rest);
    CkOAuth2_Dispose(oauth2);
    CkStringBuilder_Dispose(sbJson);
    CkJsonObject_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"
    }
  }
}