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 List Member BoardsLists the boards that the user is a member of. For more information, see https://developers.trello.com/reference#membersidboards
#include <CkJsonObject.h> #include <CkOAuth1.h> #include <CkRest.h> #include <CkJsonArray.h> void ChilkatSample(void) { // This example assumes the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. // curl --request GET \ // --url 'https://api.trello.com/1/members/{member_id}/boards?filter=all&fields=all&lists=none&memberships=none&organization=false&organization_fields=displayName' // First get our previously obtained access token. CkJsonObject jsonToken; bool success = jsonToken.LoadFile("qa_data/tokens/trello.json"); CkOAuth1 oauth1; oauth1.put_ConsumerKey("TRELLO_CONSUMER_KEY"); oauth1.put_ConsumerSecret("TRELLO_CONSUMER_SECRET"); oauth1.put_Token(jsonToken.stringOf("oauth_token")); oauth1.put_TokenSecret(jsonToken.stringOf("oauth_token_secret")); CkRest 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("api.trello.com",443,true,bAutoReconnect); if (success != true) { std::cout << rest.lastErrorText() << "\r\n"; return; } rest.SetAuthOAuth1(oauth1,false); rest.AddQueryParam("filter","all"); rest.AddQueryParam("fields","all"); rest.AddQueryParam("lists","none"); rest.AddQueryParam("memberships","normal"); rest.AddQueryParam("organization","false"); rest.AddQueryParam("organization_fields","name,displayName"); rest.AddHeader("Accept","application/json"); const char *responseBody = rest.fullRequestNoBody("GET","/1/members/member_id/boards"); if (rest.get_LastMethodSuccess() != true) { std::cout << rest.lastErrorText() << "\r\n"; return; } // We should expect a 200 response if successful. if (rest.get_ResponseStatusCode() != 200) { std::cout << "Request Header: " << "\r\n"; std::cout << rest.lastRequestHeader() << "\r\n"; std::cout << "----" << "\r\n"; std::cout << "Response StatusCode = " << rest.get_ResponseStatusCode() << "\r\n"; std::cout << "Response StatusLine: " << rest.responseStatusText() << "\r\n"; std::cout << "Response Header:" << "\r\n"; std::cout << rest.responseHeader() << "\r\n"; std::cout << responseBody << "\r\n"; return; } CkJsonArray jarr; jarr.Load(responseBody); jarr.put_EmitCompact(false); std::cout << jarr.emit() << "\r\n"; std::cout << "Success." << "\r\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 // [ // { // "name": "House Projects", // "desc": "", // "descData": null, // "closed": false, // "idOrganization": null, // "limits": null, // "pinned": null, // "shortLink": "j1hkQKKS", // "powerUps": [ // ], // "dateLastActivity": null, // "idTags": [ // ], // "datePluginDisable": null, // "creationMethod": null, // "ixUpdate": null, // "id": "5cc5fe862106bb8e05aa41e7", // "starred": false, // "url": "https://trello.com/b/j1hkQKKS/house-projects", // "prefs": { // "permissionLevel": "private", // "voting": "disabled", // "comments": "members", // "invitations": "members", // "selfJoin": false, // "cardCovers": true, // "cardAging": "regular", // "calendarFeedEnabled": false, // "background": "5cc344f6ba4cdc5f5cfc7d81", // "backgroundImage": "https://trello-backgrounds.s3.amazonaws.com/SharedBackground/2560x1709/4418c78f2f66d26932fef88aead2aff5/photo-1555985202-12975b0235dc", // "backgroundImageScaled": [ // { // "width": 140, // "height": 93, // "url": "https://trello-backgrounds.s3.amazonaws.com/SharedBackground/140x93/0aebced0ac2d8c9c4b9231b1960d28c2/photo-1555985202-12975b0235dc.jpg" // }, // ... // { // "width": 2560, // "height": 1709, // "url": "https://trello-backgrounds.s3.amazonaws.com/SharedBackground/2560x1709/4418c78f2f66d26932fef88aead2aff5/photo-1555985202-12975b0235dc" // } // ], // "backgroundTile": false, // "backgroundBrightness": "dark", // "backgroundBottomColor": "#412f23", // "backgroundTopColor": "#a99d97", // "canBePublic": true, // "canBeEnterprise": true, // "canBeOrg": true, // "canBePrivate": true, // "canInvite": true // }, // "subscribed": false, // "labelNames": { // "green": "", // "yellow": "", // "orange": "", // "red": "", // "purple": "", // "blue": "", // "sky": "", // "lime": "", // "pink": "", // "black": "" // }, // "dateLastView": "2019-04-28T19:28:18.159Z", // "shortUrl": "https://trello.com/b/j1hkQKKS", // "memberships": [ // { // "id": "5cc5fe862106bb8e05aa41e8", // "idMember": "5cc5c74067d5215921ca7677", // "memberType": "admin", // "unconfirmed": false, // "deactivated": false // } // ] // }, // { // "name": "Vacation Planning", // "desc": "", // "descData": null, // "closed": false, // "idOrganization": null, // "limits": null, // "pinned": null, // "shortLink": "QqIHvQyz", // "powerUps": [ // ], // "dateLastActivity": "2019-04-28T15:32:20.134Z", // "idTags": [ // ], // "datePluginDisable": null, // "creationMethod": "assisted", // "ixUpdate": null, // "id": "5cc5c783f5b10f8717a6b3d6", // "starred": false, // "url": "https://trello.com/b/QqIHvQyz/vacation-planning", // "prefs": { // "permissionLevel": "private", // "voting": "disabled", // "comments": "members", // "invitations": "members", // "selfJoin": true, // "cardCovers": true, // "cardAging": "regular", // "calendarFeedEnabled": false, // "background": "lime", // "backgroundImage": null, // "backgroundImageScaled": null, // "backgroundTile": false, // "backgroundBrightness": "dark", // "backgroundColor": "#4BBF6B", // "backgroundBottomColor": "#4BBF6B", // "backgroundTopColor": "#4BBF6B", // "canBePublic": true, // "canBeEnterprise": true, // "canBeOrg": true, // "canBePrivate": true, // "canInvite": true // }, // "subscribed": false, // "labelNames": { // "green": "", // "yellow": "", // "orange": "", // "red": "", // "purple": "", // "blue": "", // "sky": "", // "lime": "", // "pink": "", // "black": "" // }, // "dateLastView": "2019-04-28T19:32:21.009Z", // "shortUrl": "https://trello.com/b/QqIHvQyz", // "memberships": [ // { // "id": "5cc5c783f5b10f8717a6b3d7", // "idMember": "5cc5c74067d5215921ca7677", // "memberType": "admin", // "unconfirmed": false, // "deactivated": false // } // ] // } // ] int i; int count_i; CkJsonObject *json = 0; const char *name = 0; const char *desc = 0; const char *descData = 0; bool closed; const char *idOrganization = 0; const char *limits = 0; const char *pinned = 0; const char *shortLink = 0; const char *dateLastActivity = 0; const char *datePluginDisable = 0; const char *creationMethod = 0; const char *ixUpdate = 0; const char *id = 0; bool starred; const char *url = 0; const char *prefsPermissionLevel = 0; const char *prefsVoting = 0; const char *prefsComments = 0; const char *prefsInvitations = 0; bool prefsSelfJoin; bool prefsCardCovers; const char *prefsCardAging = 0; bool prefsCalendarFeedEnabled; const char *prefsBackground = 0; const char *prefsBackgroundImage = 0; bool prefsBackgroundTile; const char *prefsBackgroundBrightness = 0; const char *prefsBackgroundBottomColor = 0; const char *prefsBackgroundTopColor = 0; bool prefsCanBePublic; bool prefsCanBeEnterprise; bool prefsCanBeOrg; bool prefsCanBePrivate; bool prefsCanInvite; bool subscribed; const char *labelNamesGreen = 0; const char *labelNamesYellow = 0; const char *labelNamesOrange = 0; const char *labelNamesRed = 0; const char *labelNamesPurple = 0; const char *labelNamesBlue = 0; const char *labelNamesSky = 0; const char *labelNamesLime = 0; const char *labelNamesPink = 0; const char *labelNamesBlack = 0; const char *dateLastView = 0; const char *shortUrl = 0; const char *prefsBackgroundImageScaled = 0; const char *prefsBackgroundColor = 0; int j; int count_j; int width; int height; const char *idMember = 0; const char *memberType = 0; bool unconfirmed; bool deactivated; i = 0; count_i = jarr.get_Size(); while (i < count_i) { json = jarr.ObjectAt(i); name = json->stringOf("name"); desc = json->stringOf("desc"); descData = json->stringOf("descData"); closed = json->BoolOf("closed"); idOrganization = json->stringOf("idOrganization"); limits = json->stringOf("limits"); pinned = json->stringOf("pinned"); shortLink = json->stringOf("shortLink"); dateLastActivity = json->stringOf("dateLastActivity"); datePluginDisable = json->stringOf("datePluginDisable"); creationMethod = json->stringOf("creationMethod"); ixUpdate = json->stringOf("ixUpdate"); id = json->stringOf("id"); starred = json->BoolOf("starred"); url = json->stringOf("url"); prefsPermissionLevel = json->stringOf("prefs.permissionLevel"); prefsVoting = json->stringOf("prefs.voting"); prefsComments = json->stringOf("prefs.comments"); prefsInvitations = json->stringOf("prefs.invitations"); prefsSelfJoin = json->BoolOf("prefs.selfJoin"); prefsCardCovers = json->BoolOf("prefs.cardCovers"); prefsCardAging = json->stringOf("prefs.cardAging"); prefsCalendarFeedEnabled = json->BoolOf("prefs.calendarFeedEnabled"); prefsBackground = json->stringOf("prefs.background"); prefsBackgroundImage = json->stringOf("prefs.backgroundImage"); prefsBackgroundTile = json->BoolOf("prefs.backgroundTile"); prefsBackgroundBrightness = json->stringOf("prefs.backgroundBrightness"); prefsBackgroundBottomColor = json->stringOf("prefs.backgroundBottomColor"); prefsBackgroundTopColor = json->stringOf("prefs.backgroundTopColor"); prefsCanBePublic = json->BoolOf("prefs.canBePublic"); prefsCanBeEnterprise = json->BoolOf("prefs.canBeEnterprise"); prefsCanBeOrg = json->BoolOf("prefs.canBeOrg"); prefsCanBePrivate = json->BoolOf("prefs.canBePrivate"); prefsCanInvite = json->BoolOf("prefs.canInvite"); subscribed = json->BoolOf("subscribed"); labelNamesGreen = json->stringOf("labelNames.green"); labelNamesYellow = json->stringOf("labelNames.yellow"); labelNamesOrange = json->stringOf("labelNames.orange"); labelNamesRed = json->stringOf("labelNames.red"); labelNamesPurple = json->stringOf("labelNames.purple"); labelNamesBlue = json->stringOf("labelNames.blue"); labelNamesSky = json->stringOf("labelNames.sky"); labelNamesLime = json->stringOf("labelNames.lime"); labelNamesPink = json->stringOf("labelNames.pink"); labelNamesBlack = json->stringOf("labelNames.black"); dateLastView = json->stringOf("dateLastView"); shortUrl = json->stringOf("shortUrl"); prefsBackgroundImageScaled = json->stringOf("prefs.backgroundImageScaled"); prefsBackgroundColor = json->stringOf("prefs.backgroundColor"); j = 0; count_j = json->SizeOfArray("powerUps"); while (j < count_j) { json->put_J(j); // ... j = j + 1; } j = 0; count_j = json->SizeOfArray("idTags"); while (j < count_j) { json->put_J(j); // ... j = j + 1; } j = 0; count_j = json->SizeOfArray("prefs.backgroundImageScaled"); while (j < count_j) { json->put_J(j); width = json->IntOf("prefs.backgroundImageScaled[j].width"); height = json->IntOf("prefs.backgroundImageScaled[j].height"); url = json->stringOf("prefs.backgroundImageScaled[j].url"); j = j + 1; } j = 0; count_j = json->SizeOfArray("memberships"); while (j < count_j) { json->put_J(j); id = json->stringOf("memberships[j].id"); idMember = json->stringOf("memberships[j].idMember"); memberType = json->stringOf("memberships[j].memberType"); unconfirmed = json->BoolOf("memberships[j].unconfirmed"); deactivated = json->BoolOf("memberships[j].deactivated"); j = j + 1; } delete json; i = i + 1; } } |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.