Created
September 3, 2015 05:41
-
-
Save KitaitiMakoto/d59e525a5fc2d6099ee6 to your computer and use it in GitHub Desktop.
This file contains 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 ( | |
"os" | |
"net/url" | |
"net/http" | |
"io/ioutil" | |
"encoding/json" | |
"fmt" | |
) | |
func main() { | |
var uri url.URL | |
query := url.Values{} | |
uri.Scheme = "https" | |
uri.Host = os.Getenv("BACKLOG_SPACE_KEY") + ".backlog.jp" | |
uri.Path = "/api/v2/space" | |
query.Set("apiKey", os.Getenv("BACKLOG_API_KEY")) | |
uri.RawQuery = query.Encode() | |
resp, err := http.Get(uri.String()) | |
if err != nil { | |
fmt.Println(err) | |
} | |
defer resp.Body.Close() | |
body, err := ioutil.ReadAll(resp.Body) | |
if err != nil { | |
fmt.Println(err) | |
} | |
var info map[string]interface{} | |
json_err := json.Unmarshal(body, &info) | |
if json_err != nil { | |
fmt.Println(json_err) | |
} | |
fmt.Println("Space key:", os.Getenv("BACKLOG_SPACE_KEY")) | |
fmt.Println("API key:", os.Getenv("BACKLOG_API_KEY")) | |
fmt.Println("URI:", uri) | |
fmt.Println("Status:", resp.Status) | |
fmt.Println("Header:", resp.Header) | |
fmt.Println("Body:", string(body)) | |
for k, v := range(info) { | |
fmt.Println(k, ":", v) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment