Skip to content

Instantly share code, notes, and snippets.

@stevelippert
Created May 12, 2014 00:11
Show Gist options
  • Select an option

  • Save stevelippert/b4ff63d932ab482ebd3d to your computer and use it in GitHub Desktop.

Select an option

Save stevelippert/b4ff63d932ab482ebd3d to your computer and use it in GitHub Desktop.
WeatherSTEM API Example in Go
package main
import (
"net/http"
"strings"
"io/ioutil"
"fmt"
"crypto/tls"
)
func main() {
tr := &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify : true},
}
client := &http.Client{Transport: tr}
apiUrl := "https://leonschools.weatherstem.com/api"
vars := (`{"api_key":"cs9ynb6t","stations":["canopyoaks"]}`)
b := strings.NewReader(vars)
resp, err := client.Post(apiUrl, "application/json", b)
if err != nil {
fmt.Println(err)
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
fmt.Printf("%s\n", string(body))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment