//Auth attempts to authenticate with Hitbox.tv to get access token, which is needed for chat connection.
Auth attempts to authenticate with Hitbox.tv to get access token, which is needed for chat connection.
// Auth attempts to authenticate with Hitbox . tv to get access token which is needed for chat connection .
func (bot *Hitbot) Auth(pass string) {
	temp := "login=" + bot.name + "&pass=" + pass
	body := strings.NewReader(temp)
	headers := map[string][]string{"Content-Type": []string{"application/x-www-form-urlencoded"}}
	st, _, r, err := http.DefaultClient.Post("http://api.hitbox.tv/auth/token", headers, body)
	if err != nil {
		log.Fatal(err)
	}
	if r != nil {
		defer r.Close()
	}
	res := make([]byte, 56)
	r.Read(res)
	if err := json.Unmarshal(res, &bot.auth); err != nil {
		log.Fatalf("Could not parse JSON: %v", err)
	}
	if st.Code != 200 {
		log.Fatalf("Authentication failed! (status %v)", st.Code)
	}
	log.Print("Successfully authenticated with Hitbox.tv")
}
func ( bot * Hitbot ) Auth ( pass string ) { temp := " " + bot . name + " " + pass body := strings . NewReader ( temp ) headers := map [ string ] [ ] string { " " : [ ] string { " " } } st , _ , r , err := http . DefaultClient . Post ( " " , headers , body ) if err != nil { log . Fatal ( err ) } if r != nil { defer r . Close ( ) } res := make ( [ ] byte , 56 ) r . Read ( res ) if err := json . Unmarshal ( res , & bot . auth ) ; err != nil { log . Fatalf ( " " , err ) } if st . Code != 200 { log . Fatalf ( " " , st . Code ) } log . Print ( " " ) }
Auth attempts to authenticate with Hitbox.tv to get access token, which is needed for chat connection.
Auth attempts to authenticate with Hitbox . tv to get access token which is needed for chat connection .