Skip to content

Instantly share code, notes, and snippets.

@amiceli
Created December 10, 2017 12:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amiceli/41368ca4d197c4ae61632ba18b50386d to your computer and use it in GitHub Desktop.
Save amiceli/41368ca4d197c4ae61632ba18b50386d to your computer and use it in GitHub Desktop.
List trello organization members in go-lang
package main
import "fmt"
import "net/http"
import "io/ioutil"
import "encoding/json"
import "bytes"
type Obj struct {
FullName string `json:"fullName"`
Username string `json:"username"`
Id string `json:"id"`
}
func main() {
fmt.Printf("hello, world\n")
var key string = "your-api-key"
var token string = "your-api-token"
var orga string = "your-organization-name"
var url = fmt.Sprintf("https://api.trello.com/1/organizations/%s/members", orga)
var urlQuery = fmt.Sprintf("?key=%s&token=%s", key, token)
var fullUrl string = url + urlQuery
fmt.Println(fullUrl)
resp, err := http.Get(fullUrl)
body, err2 := ioutil.ReadAll(resp.Body)
if err2 != nil {
panic(err.Error())
}
people1 := []Obj{}
decoder := json.NewDecoder(bytes.NewBuffer(body))
jsonErr := decoder.Decode(&people1)
if jsonErr != nil {
panic(jsonErr)
}
fmt.Println(people1)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment