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
(PureBasic) Trello List Member BoardsLists the boards that the user is a member of. For more information, see https://developers.trello.com/reference#membersidboards
IncludeFile "CkRest.pb" IncludeFile "CkJsonObject.pb" IncludeFile "CkJsonArray.pb" IncludeFile "CkOAuth1.pb" Procedure ChilkatExample() ; 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. jsonToken.i = CkJsonObject::ckCreate() If jsonToken.i = 0 Debug "Failed to create object." ProcedureReturn EndIf success.i = CkJsonObject::ckLoadFile(jsonToken,"qa_data/tokens/trello.json") oauth1.i = CkOAuth1::ckCreate() If oauth1.i = 0 Debug "Failed to create object." ProcedureReturn EndIf CkOAuth1::setCkConsumerKey(oauth1, "TRELLO_CONSUMER_KEY") CkOAuth1::setCkConsumerSecret(oauth1, "TRELLO_CONSUMER_SECRET") CkOAuth1::setCkToken(oauth1, CkJsonObject::ckStringOf(jsonToken,"oauth_token")) CkOAuth1::setCkTokenSecret(oauth1, CkJsonObject::ckStringOf(jsonToken,"oauth_token_secret")) rest.i = CkRest::ckCreate() If rest.i = 0 Debug "Failed to create object." ProcedureReturn EndIf ; 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.i = 1 success = CkRest::ckConnect(rest,"api.trello.com",443,1,bAutoReconnect) If success <> 1 Debug CkRest::ckLastErrorText(rest) CkJsonObject::ckDispose(jsonToken) CkOAuth1::ckDispose(oauth1) CkRest::ckDispose(rest) ProcedureReturn EndIf CkRest::ckSetAuthOAuth1(rest,oauth1,0) CkRest::ckAddQueryParam(rest,"filter","all") CkRest::ckAddQueryParam(rest,"fields","all") CkRest::ckAddQueryParam(rest,"lists","none") CkRest::ckAddQueryParam(rest,"memberships","normal") CkRest::ckAddQueryParam(rest,"organization","false") CkRest::ckAddQueryParam(rest,"organization_fields","name,displayName") CkRest::ckAddHeader(rest,"Accept","application/json") responseBody.s = CkRest::ckFullRequestNoBody(rest,"GET","/1/members/member_id/boards") If CkRest::ckLastMethodSuccess(rest) <> 1 Debug CkRest::ckLastErrorText(rest) CkJsonObject::ckDispose(jsonToken) CkOAuth1::ckDispose(oauth1) CkRest::ckDispose(rest) ProcedureReturn EndIf ; We should expect a 200 response if successful. If CkRest::ckResponseStatusCode(rest) <> 200 Debug "Request Header: " Debug CkRest::ckLastRequestHeader(rest) Debug "----" Debug "Response StatusCode = " + Str(CkRest::ckResponseStatusCode(rest)) Debug "Response StatusLine: " + CkRest::ckResponseStatusText(rest) Debug "Response Header:" Debug CkRest::ckResponseHeader(rest) Debug responseBody CkJsonObject::ckDispose(jsonToken) CkOAuth1::ckDispose(oauth1) CkRest::ckDispose(rest) ProcedureReturn EndIf jarr.i = CkJsonArray::ckCreate() If jarr.i = 0 Debug "Failed to create object." ProcedureReturn EndIf CkJsonArray::ckLoad(jarr,responseBody) CkJsonArray::setCkEmitCompact(jarr, 0) Debug CkJsonArray::ckEmit(jarr) Debug "Success." ; 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 ; } ; ] ; } ; ] i.i count_i.i json.i name.s desc.s descData.s closed.i idOrganization.s limits.s pinned.s shortLink.s dateLastActivity.s datePluginDisable.s creationMethod.s ixUpdate.s id.s starred.i url.s prefsPermissionLevel.s prefsVoting.s prefsComments.s prefsInvitations.s prefsSelfJoin.i prefsCardCovers.i prefsCardAging.s prefsCalendarFeedEnabled.i prefsBackground.s prefsBackgroundImage.s prefsBackgroundTile.i prefsBackgroundBrightness.s prefsBackgroundBottomColor.s prefsBackgroundTopColor.s prefsCanBePublic.i prefsCanBeEnterprise.i prefsCanBeOrg.i prefsCanBePrivate.i prefsCanInvite.i subscribed.i labelNamesGreen.s labelNamesYellow.s labelNamesOrange.s labelNamesRed.s labelNamesPurple.s labelNamesBlue.s labelNamesSky.s labelNamesLime.s labelNamesPink.s labelNamesBlack.s dateLastView.s shortUrl.s prefsBackgroundImageScaled.s prefsBackgroundColor.s j.i count_j.i width.i height.i idMember.s memberType.s unconfirmed.i deactivated.i i = 0 count_i = CkJsonArray::ckSize(jarr) While i < count_i json = CkJsonArray::ckObjectAt(jarr,i) name = CkJsonObject::ckStringOf(json,"name") desc = CkJsonObject::ckStringOf(json,"desc") descData = CkJsonObject::ckStringOf(json,"descData") closed = CkJsonObject::ckBoolOf(json,"closed") idOrganization = CkJsonObject::ckStringOf(json,"idOrganization") limits = CkJsonObject::ckStringOf(json,"limits") pinned = CkJsonObject::ckStringOf(json,"pinned") shortLink = CkJsonObject::ckStringOf(json,"shortLink") dateLastActivity = CkJsonObject::ckStringOf(json,"dateLastActivity") datePluginDisable = CkJsonObject::ckStringOf(json,"datePluginDisable") creationMethod = CkJsonObject::ckStringOf(json,"creationMethod") ixUpdate = CkJsonObject::ckStringOf(json,"ixUpdate") id = CkJsonObject::ckStringOf(json,"id") starred = CkJsonObject::ckBoolOf(json,"starred") url = CkJsonObject::ckStringOf(json,"url") prefsPermissionLevel = CkJsonObject::ckStringOf(json,"prefs.permissionLevel") prefsVoting = CkJsonObject::ckStringOf(json,"prefs.voting") prefsComments = CkJsonObject::ckStringOf(json,"prefs.comments") prefsInvitations = CkJsonObject::ckStringOf(json,"prefs.invitations") prefsSelfJoin = CkJsonObject::ckBoolOf(json,"prefs.selfJoin") prefsCardCovers = CkJsonObject::ckBoolOf(json,"prefs.cardCovers") prefsCardAging = CkJsonObject::ckStringOf(json,"prefs.cardAging") prefsCalendarFeedEnabled = CkJsonObject::ckBoolOf(json,"prefs.calendarFeedEnabled") prefsBackground = CkJsonObject::ckStringOf(json,"prefs.background") prefsBackgroundImage = CkJsonObject::ckStringOf(json,"prefs.backgroundImage") prefsBackgroundTile = CkJsonObject::ckBoolOf(json,"prefs.backgroundTile") prefsBackgroundBrightness = CkJsonObject::ckStringOf(json,"prefs.backgroundBrightness") prefsBackgroundBottomColor = CkJsonObject::ckStringOf(json,"prefs.backgroundBottomColor") prefsBackgroundTopColor = CkJsonObject::ckStringOf(json,"prefs.backgroundTopColor") prefsCanBePublic = CkJsonObject::ckBoolOf(json,"prefs.canBePublic") prefsCanBeEnterprise = CkJsonObject::ckBoolOf(json,"prefs.canBeEnterprise") prefsCanBeOrg = CkJsonObject::ckBoolOf(json,"prefs.canBeOrg") prefsCanBePrivate = CkJsonObject::ckBoolOf(json,"prefs.canBePrivate") prefsCanInvite = CkJsonObject::ckBoolOf(json,"prefs.canInvite") subscribed = CkJsonObject::ckBoolOf(json,"subscribed") labelNamesGreen = CkJsonObject::ckStringOf(json,"labelNames.green") labelNamesYellow = CkJsonObject::ckStringOf(json,"labelNames.yellow") labelNamesOrange = CkJsonObject::ckStringOf(json,"labelNames.orange") labelNamesRed = CkJsonObject::ckStringOf(json,"labelNames.red") labelNamesPurple = CkJsonObject::ckStringOf(json,"labelNames.purple") labelNamesBlue = CkJsonObject::ckStringOf(json,"labelNames.blue") labelNamesSky = CkJsonObject::ckStringOf(json,"labelNames.sky") labelNamesLime = CkJsonObject::ckStringOf(json,"labelNames.lime") labelNamesPink = CkJsonObject::ckStringOf(json,"labelNames.pink") labelNamesBlack = CkJsonObject::ckStringOf(json,"labelNames.black") dateLastView = CkJsonObject::ckStringOf(json,"dateLastView") shortUrl = CkJsonObject::ckStringOf(json,"shortUrl") prefsBackgroundImageScaled = CkJsonObject::ckStringOf(json,"prefs.backgroundImageScaled") prefsBackgroundColor = CkJsonObject::ckStringOf(json,"prefs.backgroundColor") j = 0 count_j = CkJsonObject::ckSizeOfArray(json,"powerUps") While j < count_j CkJsonObject::setCkJ(json, j) ; ... j = j + 1 Wend j = 0 count_j = CkJsonObject::ckSizeOfArray(json,"idTags") While j < count_j CkJsonObject::setCkJ(json, j) ; ... j = j + 1 Wend j = 0 count_j = CkJsonObject::ckSizeOfArray(json,"prefs.backgroundImageScaled") While j < count_j CkJsonObject::setCkJ(json, j) width = CkJsonObject::ckIntOf(json,"prefs.backgroundImageScaled[j].width") height = CkJsonObject::ckIntOf(json,"prefs.backgroundImageScaled[j].height") url = CkJsonObject::ckStringOf(json,"prefs.backgroundImageScaled[j].url") j = j + 1 Wend j = 0 count_j = CkJsonObject::ckSizeOfArray(json,"memberships") While j < count_j CkJsonObject::setCkJ(json, j) id = CkJsonObject::ckStringOf(json,"memberships[j].id") idMember = CkJsonObject::ckStringOf(json,"memberships[j].idMember") memberType = CkJsonObject::ckStringOf(json,"memberships[j].memberType") unconfirmed = CkJsonObject::ckBoolOf(json,"memberships[j].unconfirmed") deactivated = CkJsonObject::ckBoolOf(json,"memberships[j].deactivated") j = j + 1 Wend CkJsonObject::ckDispose(json) i = i + 1 Wend CkJsonObject::ckDispose(jsonToken) CkOAuth1::ckDispose(oauth1) CkRest::ckDispose(rest) CkJsonArray::ckDispose(jarr) ProcedureReturn EndProcedure |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.