Esempio n. 1
0
func (tv *AdapterLGTV47LS5700) initSession(dev *api.Thing) {
	log.Printf("initSession")
	host := dev.GetAttributeValue("host").Value.(string)
	url := "http://" + host + ":8080/roap/api/auth"
	pairingKey := dev.GetAttributeValue("pairingKey").Value.(string)
	payload := "<auth><type>AuthReq</type><value>" + pairingKey + "</value></auth>"

	client := &http.Client{}
	post_data := strings.NewReader(payload)
	req, _ := http.NewRequest("POST", url, post_data)
	req.Header.Add("Content-Type", "application/atom+xml")

	_, err := client.Do(req)
	if err != nil {
		log.Print(err)
	}
}