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
(Unicode C++) Trello Create New BoardCreate a new board. For more information, see https://developers.trello.com/reference#boardsid
#include <CkJsonObjectW.h> #include <CkOAuth1W.h> #include <CkRestW.h> void ChilkatSample(void) { // 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. CkJsonObjectW jsonToken; bool success = jsonToken.LoadFile(L"qa_data/tokens/trello.json"); CkOAuth1W oauth1; oauth1.put_ConsumerKey(L"TRELLO_CONSUMER_KEY"); oauth1.put_ConsumerSecret(L"TRELLO_CONSUMER_SECRET"); oauth1.put_Token(jsonToken.stringOf(L"oauth_token")); oauth1.put_TokenSecret(jsonToken.stringOf(L"oauth_token_secret")); CkRestW rest; // 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. bool bAutoReconnect = true; success = rest.Connect(L"api.trello.com",443,true,bAutoReconnect); if (success != true) { wprintf(L"%s\n",rest.lastErrorText()); return; } rest.SetAuthOAuth1(oauth1,false); rest.AddQueryParam(L"name",L"Football & Rugby"); rest.AddQueryParam(L"defaultLabels",L"true"); rest.AddQueryParam(L"defaultLists",L"true"); rest.AddQueryParam(L"keepFromSource",L"none"); rest.AddQueryParam(L"prefs_permissionLevel",L"private"); rest.AddQueryParam(L"prefs_voting",L"disabled"); rest.AddQueryParam(L"prefs_comments",L"members"); rest.AddQueryParam(L"prefs_invitations",L"members"); rest.AddQueryParam(L"prefs_selfJoin",L"true"); rest.AddQueryParam(L"prefs_cardCovers",L"true"); rest.AddQueryParam(L"prefs_background",L"blue"); rest.AddQueryParam(L"prefs_cardAging",L"regular"); rest.AddHeader(L"Accept",L"application/json"); const wchar_t *responseBody = rest.fullRequestFormUrlEncoded(L"POST",L"/1/boards"); if (rest.get_LastMethodSuccess() != true) { wprintf(L"%s\n",rest.lastErrorText()); return; } // We should expect a 200 response if successful. if (rest.get_ResponseStatusCode() != 200) { wprintf(L"Request Header: \n"); wprintf(L"%s\n",rest.lastRequestHeader()); wprintf(L"----\n"); wprintf(L"Response StatusCode = %d\n",rest.get_ResponseStatusCode()); wprintf(L"Response StatusLine: %s\n",rest.responseStatusText()); wprintf(L"Response Header:\n"); wprintf(L"%s\n",rest.responseHeader()); wprintf(L"%s\n",responseBody); return; } CkJsonObjectW json; json.Load(responseBody); json.put_EmitCompact(false); wprintf(L"%s\n",json.emit()); wprintf(L"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": {} // } const wchar_t *id = 0; const wchar_t *name = 0; const wchar_t *desc = 0; const wchar_t *descData = 0; bool closed; const wchar_t *idOrganization = 0; bool pinned; const wchar_t *url = 0; const wchar_t *shortUrl = 0; const wchar_t *prefsPermissionLevel = 0; const wchar_t *prefsVoting = 0; const wchar_t *prefsComments = 0; const wchar_t *prefsInvitations = 0; bool prefsSelfJoin; bool prefsCardCovers; const wchar_t *prefsCardAging = 0; bool prefsCalendarFeedEnabled; const wchar_t *prefsBackground = 0; const wchar_t *prefsBackgroundImage = 0; const wchar_t *prefsBackgroundImageScaled = 0; bool prefsBackgroundTile; const wchar_t *prefsBackgroundBrightness = 0; const wchar_t *prefsBackgroundColor = 0; const wchar_t *prefsBackgroundBottomColor = 0; const wchar_t *prefsBackgroundTopColor = 0; bool prefsCanBePublic; bool prefsCanBeEnterprise; bool prefsCanBeOrg; bool prefsCanBePrivate; bool prefsCanInvite; const wchar_t *labelNamesGreen = 0; const wchar_t *labelNamesYellow = 0; const wchar_t *labelNamesOrange = 0; const wchar_t *labelNamesRed = 0; const wchar_t *labelNamesPurple = 0; const wchar_t *labelNamesBlue = 0; const wchar_t *labelNamesSky = 0; const wchar_t *labelNamesLime = 0; const wchar_t *labelNamesPink = 0; const wchar_t *labelNamesBlack = 0; id = json.stringOf(L"id"); name = json.stringOf(L"name"); desc = json.stringOf(L"desc"); descData = json.stringOf(L"descData"); closed = json.BoolOf(L"closed"); idOrganization = json.stringOf(L"idOrganization"); pinned = json.BoolOf(L"pinned"); url = json.stringOf(L"url"); shortUrl = json.stringOf(L"shortUrl"); prefsPermissionLevel = json.stringOf(L"prefs.permissionLevel"); prefsVoting = json.stringOf(L"prefs.voting"); prefsComments = json.stringOf(L"prefs.comments"); prefsInvitations = json.stringOf(L"prefs.invitations"); prefsSelfJoin = json.BoolOf(L"prefs.selfJoin"); prefsCardCovers = json.BoolOf(L"prefs.cardCovers"); prefsCardAging = json.stringOf(L"prefs.cardAging"); prefsCalendarFeedEnabled = json.BoolOf(L"prefs.calendarFeedEnabled"); prefsBackground = json.stringOf(L"prefs.background"); prefsBackgroundImage = json.stringOf(L"prefs.backgroundImage"); prefsBackgroundImageScaled = json.stringOf(L"prefs.backgroundImageScaled"); prefsBackgroundTile = json.BoolOf(L"prefs.backgroundTile"); prefsBackgroundBrightness = json.stringOf(L"prefs.backgroundBrightness"); prefsBackgroundColor = json.stringOf(L"prefs.backgroundColor"); prefsBackgroundBottomColor = json.stringOf(L"prefs.backgroundBottomColor"); prefsBackgroundTopColor = json.stringOf(L"prefs.backgroundTopColor"); prefsCanBePublic = json.BoolOf(L"prefs.canBePublic"); prefsCanBeEnterprise = json.BoolOf(L"prefs.canBeEnterprise"); prefsCanBeOrg = json.BoolOf(L"prefs.canBeOrg"); prefsCanBePrivate = json.BoolOf(L"prefs.canBePrivate"); prefsCanInvite = json.BoolOf(L"prefs.canInvite"); labelNamesGreen = json.stringOf(L"labelNames.green"); labelNamesYellow = json.stringOf(L"labelNames.yellow"); labelNamesOrange = json.stringOf(L"labelNames.orange"); labelNamesRed = json.stringOf(L"labelNames.red"); labelNamesPurple = json.stringOf(L"labelNames.purple"); labelNamesBlue = json.stringOf(L"labelNames.blue"); labelNamesSky = json.stringOf(L"labelNames.sky"); labelNamesLime = json.stringOf(L"labelNames.lime"); labelNamesPink = json.stringOf(L"labelNames.pink"); labelNamesBlack = json.stringOf(L"labelNames.black"); } |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.