Created
December 10, 2017 12:31
-
-
Save amiceli/41368ca4d197c4ae61632ba18b50386d to your computer and use it in GitHub Desktop.
List trello organization members in go-lang
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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