Skip to content

Instantly share code, notes, and snippets.

@Ovinatter
Created December 5, 2014 07:35
Show Gist options
  • Save Ovinatter/f4055edb852c1f0ea7bd to your computer and use it in GitHub Desktop.
Save Ovinatter/f4055edb852c1f0ea7bd to your computer and use it in GitHub Desktop.
c := appengine.NewContext(r)
client := urlfetch.Client(c)
resp, err := client.Get("https://api.instagram.com/v1/media/popular?client_id=01f47c48216e42d3a9e4d2756cdbc7cb")
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
body, bodyErr := ioutil.ReadAll(resp.Body)
if bodyErr != nil {
http.Error(w, bodyErr.Error(), http.StatusInternalServerError)
}
defer resp.Body.Close()
var m Meta
err2 := json.Unmarshal(body, &m)
if err2 != nil {
fmt.Fprintln(os.Stderr, err2)
} else {
fmt.Fprintf(w, m.Meta.Code)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment