Lua
Lua
Trello List Member Boards
See more Trello Examples
Lists the boards that the user is a member of.For more information, see https://developers.trello.com/reference#membersidboards
Chilkat Lua Downloads
local chilkat = require("chilkat")
-- 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.
local jsonToken = chilkat.JsonObject.new()
local success = jsonToken:load_file("qa_data/tokens/trello.json")
local oauth1 = chilkat.OAuth1.new()
oauth1.consumer_key = "TRELLO_CONSUMER_KEY"
oauth1.consumer_secret = "TRELLO_CONSUMER_SECRET"
oauth1.token = jsonToken:string_of("oauth_token")
oauth1.token_secret = jsonToken:string_of("oauth_token_secret")
local rest = chilkat.Rest.new()
-- 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.
local bAutoReconnect = true
success = rest:connect("api.trello.com", 443, true, bAutoReconnect)
if not success then
print(rest.last_error_text)
return
end
rest:set_auth_oauth1(oauth1, false)
rest:add_query_param("filter", "all")
rest:add_query_param("fields", "all")
rest:add_query_param("lists", "none")
rest:add_query_param("memberships", "normal")
rest:add_query_param("organization", "false")
rest:add_query_param("organization_fields", "name,displayName")
rest:add_header("Accept", "application/json")
local responseBody = rest:full_request_no_body("GET", "/1/members/member_id/boards")
if not rest.last_method_success then
print(rest.last_error_text)
return
end
-- We should expect a 200 response if successful.
if rest.response_status_code ~= 200 then
print("Request Header: ")
print(rest.last_request_header)
print("----")
print("Response StatusCode = " .. rest.response_status_code)
print("Response StatusLine: " .. rest.response_status_text)
print("Response Header:")
print(rest.response_header)
print(responseBody)
return
end
local jarr = chilkat.JsonArray.new()
jarr:load(responseBody)
jarr.emit_compact = false
print(jarr:emit())
print("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
-- }
-- ]
-- }
-- ]
local json
local name = ""
local desc = ""
local descData = ""
local closed = false
local idOrganization = ""
local limits = ""
local pinned = ""
local shortLink = ""
local dateLastActivity = ""
local datePluginDisable = ""
local creationMethod = ""
local ixUpdate = ""
local id = ""
local starred = false
local url = ""
local prefsPermissionLevel = ""
local prefsVoting = ""
local prefsComments = ""
local prefsInvitations = ""
local prefsSelfJoin = false
local prefsCardCovers = false
local prefsCardAging = ""
local prefsCalendarFeedEnabled = false
local prefsBackground = ""
local prefsBackgroundImage = ""
local prefsBackgroundTile = false
local prefsBackgroundBrightness = ""
local prefsBackgroundBottomColor = ""
local prefsBackgroundTopColor = ""
local prefsCanBePublic = false
local prefsCanBeEnterprise = false
local prefsCanBeOrg = false
local prefsCanBePrivate = false
local prefsCanInvite = false
local subscribed = false
local labelNamesGreen = ""
local labelNamesYellow = ""
local labelNamesOrange = ""
local labelNamesRed = ""
local labelNamesPurple = ""
local labelNamesBlue = ""
local labelNamesSky = ""
local labelNamesLime = ""
local labelNamesPink = ""
local labelNamesBlack = ""
local dateLastView = ""
local shortUrl = ""
local prefsBackgroundImageScaled = ""
local prefsBackgroundColor = ""
local j = 0
local count_j = 0
local width = 0
local height = 0
local idMember = ""
local memberType = ""
local unconfirmed = false
local deactivated = false
local i = 0
local count_i = jarr.size
while i < count_i do
json = jarr:object_at(i)
name = json:string_of("name")
desc = json:string_of("desc")
descData = json:string_of("descData")
closed = json:bool_of("closed")
idOrganization = json:string_of("idOrganization")
limits = json:string_of("limits")
pinned = json:string_of("pinned")
shortLink = json:string_of("shortLink")
dateLastActivity = json:string_of("dateLastActivity")
datePluginDisable = json:string_of("datePluginDisable")
creationMethod = json:string_of("creationMethod")
ixUpdate = json:string_of("ixUpdate")
id = json:string_of("id")
starred = json:bool_of("starred")
url = json:string_of("url")
prefsPermissionLevel = json:string_of("prefs.permissionLevel")
prefsVoting = json:string_of("prefs.voting")
prefsComments = json:string_of("prefs.comments")
prefsInvitations = json:string_of("prefs.invitations")
prefsSelfJoin = json:bool_of("prefs.selfJoin")
prefsCardCovers = json:bool_of("prefs.cardCovers")
prefsCardAging = json:string_of("prefs.cardAging")
prefsCalendarFeedEnabled = json:bool_of("prefs.calendarFeedEnabled")
prefsBackground = json:string_of("prefs.background")
prefsBackgroundImage = json:string_of("prefs.backgroundImage")
prefsBackgroundTile = json:bool_of("prefs.backgroundTile")
prefsBackgroundBrightness = json:string_of("prefs.backgroundBrightness")
prefsBackgroundBottomColor = json:string_of("prefs.backgroundBottomColor")
prefsBackgroundTopColor = json:string_of("prefs.backgroundTopColor")
prefsCanBePublic = json:bool_of("prefs.canBePublic")
prefsCanBeEnterprise = json:bool_of("prefs.canBeEnterprise")
prefsCanBeOrg = json:bool_of("prefs.canBeOrg")
prefsCanBePrivate = json:bool_of("prefs.canBePrivate")
prefsCanInvite = json:bool_of("prefs.canInvite")
subscribed = json:bool_of("subscribed")
labelNamesGreen = json:string_of("labelNames.green")
labelNamesYellow = json:string_of("labelNames.yellow")
labelNamesOrange = json:string_of("labelNames.orange")
labelNamesRed = json:string_of("labelNames.red")
labelNamesPurple = json:string_of("labelNames.purple")
labelNamesBlue = json:string_of("labelNames.blue")
labelNamesSky = json:string_of("labelNames.sky")
labelNamesLime = json:string_of("labelNames.lime")
labelNamesPink = json:string_of("labelNames.pink")
labelNamesBlack = json:string_of("labelNames.black")
dateLastView = json:string_of("dateLastView")
shortUrl = json:string_of("shortUrl")
prefsBackgroundImageScaled = json:string_of("prefs.backgroundImageScaled")
prefsBackgroundColor = json:string_of("prefs.backgroundColor")
j = 0
count_j = json:size_of_array("powerUps")
while j < count_j do
json.j = j
-- ...
j = j + 1
end
j = 0
count_j = json:size_of_array("idTags")
while j < count_j do
json.j = j
-- ...
j = j + 1
end
j = 0
count_j = json:size_of_array("prefs.backgroundImageScaled")
while j < count_j do
json.j = j
width = json:int_of("prefs.backgroundImageScaled[j].width")
height = json:int_of("prefs.backgroundImageScaled[j].height")
url = json:string_of("prefs.backgroundImageScaled[j].url")
j = j + 1
end
j = 0
count_j = json:size_of_array("memberships")
while j < count_j do
json.j = j
id = json:string_of("memberships[j].id")
idMember = json:string_of("memberships[j].idMember")
memberType = json:string_of("memberships[j].memberType")
unconfirmed = json:bool_of("memberships[j].unconfirmed")
deactivated = json:bool_of("memberships[j].deactivated")
j = j + 1
end
i = i + 1
end