Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
45 lines (36 sloc) 884 Bytes
package main
import "fmt"
import "net/http"
import "io/ioutil"
import "encoding/json"
type Graph struct {
Id string
Name string
Description string
Category string
Subcategory string
Link string
Namespace string
Icon_url string
Logo_url string
Company string
}
func main() {
fmt.Println("Hello, playground")
resp, err := http.Get("http://graph.facebook.com/android")
if err != nil {
fmt.Println("http.Get err: ",err)// handle error
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
fmt.Println("resp.Body: ", resp.Body)
fmt.Println("body: ",string(body))
fmt.Println("err: ",err)
var g Graph
err = json.Unmarshal(body, &g)
if err == nil {
fmt.Println("graph: ", g)
} else {
fmt.Println("graph error: ",err) // <---error at this line
}
}