Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(C) Trello Create New BoardCreate a new board. For more information, see https://developers.trello.com/reference#boardsid
#include <C_CkJsonObject.h> #include <C_CkOAuth1.h> #include <C_CkRest.h> void ChilkatSample(void) { HCkJsonObject jsonToken; BOOL success; HCkOAuth1 oauth1; HCkRest rest; BOOL bAutoReconnect; const char *responseBody; HCkJsonObject json; const char *id; const char *name; const char *desc; const char *descData; BOOL closed; const char *idOrganization; BOOL pinned; const char *url; const char *shortUrl; const char *prefsPermissionLevel; const char *prefsVoting; const char *prefsComments; const char *prefsInvitations; BOOL prefsSelfJoin; BOOL prefsCardCovers; const char *prefsCardAging; BOOL prefsCalendarFeedEnabled; const char *prefsBackground; const char *prefsBackgroundImage; const char *prefsBackgroundImageScaled; BOOL prefsBackgroundTile; const char *prefsBackgroundBrightness; const char *prefsBackgroundColor; const char *prefsBackgroundBottomColor; const char *prefsBackgroundTopColor; BOOL prefsCanBePublic; BOOL prefsCanBeEnterprise; BOOL prefsCanBeOrg; BOOL prefsCanBePrivate; BOOL prefsCanInvite; const char *labelNamesGreen; const char *labelNamesYellow; const char *labelNamesOrange; const char *labelNamesRed; const char *labelNamesPurple; const char *labelNamesBlue; const char *labelNamesSky; const char *labelNamesLime; const char *labelNamesPink; const char *labelNamesBlack; // This example assumes the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. // curl --request POST \ // --url 'https://api.trello.com/1/boards?name=name&defaultLabels=true&defaultLists=true&keepFromSource=none&prefs_permissionLevel=private // &prefs_voting=disabled&prefs_comments=members&prefs_invitations=members&prefs_selfJoin=true&prefs_cardCovers=true&prefs_background=blue&prefs_cardAging=regular' // First get our previously obtained access token. jsonToken = CkJsonObject_Create(); success = CkJsonObject_LoadFile(jsonToken,"qa_data/tokens/trello.json"); oauth1 = CkOAuth1_Create(); CkOAuth1_putConsumerKey(oauth1,"TRELLO_CONSUMER_KEY"); CkOAuth1_putConsumerSecret(oauth1,"TRELLO_CONSUMER_SECRET"); CkOAuth1_putToken(oauth1,CkJsonObject_stringOf(jsonToken,"oauth_token")); CkOAuth1_putTokenSecret(oauth1,CkJsonObject_stringOf(jsonToken,"oauth_token_secret")); rest = CkRest_Create(); // Connect using TLS. // A single REST object, once connected, can be used for many Trello REST API calls. // The auto-reconnect indicates that if the already-established HTTPS connection is closed, // then it will be automatically re-established as needed. bAutoReconnect = TRUE; success = CkRest_Connect(rest,"api.trello.com",443,TRUE,bAutoReconnect); if (success != TRUE) { printf("%s\n",CkRest_lastErrorText(rest)); CkJsonObject_Dispose(jsonToken); CkOAuth1_Dispose(oauth1); CkRest_Dispose(rest); return; } CkRest_SetAuthOAuth1(rest,oauth1,FALSE); CkRest_AddQueryParam(rest,"name","Football & Rugby"); CkRest_AddQueryParam(rest,"defaultLabels","true"); CkRest_AddQueryParam(rest,"defaultLists","true"); CkRest_AddQueryParam(rest,"keepFromSource","none"); CkRest_AddQueryParam(rest,"prefs_permissionLevel","private"); CkRest_AddQueryParam(rest,"prefs_voting","disabled"); CkRest_AddQueryParam(rest,"prefs_comments","members"); CkRest_AddQueryParam(rest,"prefs_invitations","members"); CkRest_AddQueryParam(rest,"prefs_selfJoin","true"); CkRest_AddQueryParam(rest,"prefs_cardCovers","true"); CkRest_AddQueryParam(rest,"prefs_background","blue"); CkRest_AddQueryParam(rest,"prefs_cardAging","regular"); CkRest_AddHeader(rest,"Accept","application/json"); responseBody = CkRest_fullRequestFormUrlEncoded(rest,"POST","/1/boards"); if (CkRest_getLastMethodSuccess(rest) != TRUE) { printf("%s\n",CkRest_lastErrorText(rest)); CkJsonObject_Dispose(jsonToken); CkOAuth1_Dispose(oauth1); CkRest_Dispose(rest); return; } // We should expect a 200 response if successful. if (CkRest_getResponseStatusCode(rest) != 200) { printf("Request Header: \n"); printf("%s\n",CkRest_lastRequestHeader(rest)); printf("----\n"); printf("Response StatusCode = %d\n",CkRest_getResponseStatusCode(rest)); printf("Response StatusLine: %s\n",CkRest_responseStatusText(rest)); printf("Response Header:\n"); printf("%s\n",CkRest_responseHeader(rest)); printf("%s\n",responseBody); CkJsonObject_Dispose(jsonToken); CkOAuth1_Dispose(oauth1); CkRest_Dispose(rest); return; } json = CkJsonObject_Create(); CkJsonObject_Load(json,responseBody); CkJsonObject_putEmitCompact(json,FALSE); printf("%s\n",CkJsonObject_emit(json)); printf("Success.\n"); // A sample JSON response: // (See the parsing code below...) // Use this online tool to generate parsing code from sample JSON: // Generate Parsing Code from JSON // // { // "id": "5cc606a1e2441a8a8fe3dc48", // "name": "Football", // "desc": "", // "descData": null, // "closed": false, // "idOrganization": null, // "pinned": false, // "url": "https://trello.com/b/eadpS1Pe/football", // "shortUrl": "https://trello.com/b/eadpS1Pe", // "prefs": { // "permissionLevel": "private", // "voting": "disabled", // "comments": "members", // "invitations": "members", // "selfJoin": true, // "cardCovers": true, // "cardAging": "regular", // "calendarFeedEnabled": false, // "background": "blue", // "backgroundImage": null, // "backgroundImageScaled": null, // "backgroundTile": false, // "backgroundBrightness": "dark", // "backgroundColor": "#0079BF", // "backgroundBottomColor": "#0079BF", // "backgroundTopColor": "#0079BF", // "canBePublic": true, // "canBeEnterprise": true, // "canBeOrg": true, // "canBePrivate": true, // "canInvite": true // }, // "labelNames": { // "green": "", // "yellow": "", // "orange": "", // "red": "", // "purple": "", // "blue": "", // "sky": "", // "lime": "", // "pink": "", // "black": "" // }, // "limits": {} // } id = CkJsonObject_stringOf(json,"id"); name = CkJsonObject_stringOf(json,"name"); desc = CkJsonObject_stringOf(json,"desc"); descData = CkJsonObject_stringOf(json,"descData"); closed = CkJsonObject_BoolOf(json,"closed"); idOrganization = CkJsonObject_stringOf(json,"idOrganization"); pinned = CkJsonObject_BoolOf(json,"pinned"); url = CkJsonObject_stringOf(json,"url"); shortUrl = CkJsonObject_stringOf(json,"shortUrl"); prefsPermissionLevel = CkJsonObject_stringOf(json,"prefs.permissionLevel"); prefsVoting = CkJsonObject_stringOf(json,"prefs.voting"); prefsComments = CkJsonObject_stringOf(json,"prefs.comments"); prefsInvitations = CkJsonObject_stringOf(json,"prefs.invitations"); prefsSelfJoin = CkJsonObject_BoolOf(json,"prefs.selfJoin"); prefsCardCovers = CkJsonObject_BoolOf(json,"prefs.cardCovers"); prefsCardAging = CkJsonObject_stringOf(json,"prefs.cardAging"); prefsCalendarFeedEnabled = CkJsonObject_BoolOf(json,"prefs.calendarFeedEnabled"); prefsBackground = CkJsonObject_stringOf(json,"prefs.background"); prefsBackgroundImage = CkJsonObject_stringOf(json,"prefs.backgroundImage"); prefsBackgroundImageScaled = CkJsonObject_stringOf(json,"prefs.backgroundImageScaled"); prefsBackgroundTile = CkJsonObject_BoolOf(json,"prefs.backgroundTile"); prefsBackgroundBrightness = CkJsonObject_stringOf(json,"prefs.backgroundBrightness"); prefsBackgroundColor = CkJsonObject_stringOf(json,"prefs.backgroundColor"); prefsBackgroundBottomColor = CkJsonObject_stringOf(json,"prefs.backgroundBottomColor"); prefsBackgroundTopColor = CkJsonObject_stringOf(json,"prefs.backgroundTopColor"); prefsCanBePublic = CkJsonObject_BoolOf(json,"prefs.canBePublic"); prefsCanBeEnterprise = CkJsonObject_BoolOf(json,"prefs.canBeEnterprise"); prefsCanBeOrg = CkJsonObject_BoolOf(json,"prefs.canBeOrg"); prefsCanBePrivate = CkJsonObject_BoolOf(json,"prefs.canBePrivate"); prefsCanInvite = CkJsonObject_BoolOf(json,"prefs.canInvite"); labelNamesGreen = CkJsonObject_stringOf(json,"labelNames.green"); labelNamesYellow = CkJsonObject_stringOf(json,"labelNames.yellow"); labelNamesOrange = CkJsonObject_stringOf(json,"labelNames.orange"); labelNamesRed = CkJsonObject_stringOf(json,"labelNames.red"); labelNamesPurple = CkJsonObject_stringOf(json,"labelNames.purple"); labelNamesBlue = CkJsonObject_stringOf(json,"labelNames.blue"); labelNamesSky = CkJsonObject_stringOf(json,"labelNames.sky"); labelNamesLime = CkJsonObject_stringOf(json,"labelNames.lime"); labelNamesPink = CkJsonObject_stringOf(json,"labelNames.pink"); labelNamesBlack = CkJsonObject_stringOf(json,"labelNames.black"); CkJsonObject_Dispose(jsonToken); CkOAuth1_Dispose(oauth1); CkRest_Dispose(rest); CkJsonObject_Dispose(json); } |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.