package clublog import ( "fmt" "net/http" "net/url" "strings" "git.rouggy.com/CloudlogUDP/config" "git.rouggy.com/CloudlogUDP/qso" ) type ClublogAPI struct { Email string `json:"email"` Password string `json:"password"` Callsign string `json:"callsign"` ADIF string `json:"adif"` APIKey string `json:"api"` } func SendClublogMsg(qso qso.QSO, config config.Config) { QSOData := qso.Call + qso.Band + qso.Mode + qso.Freq + qso.QSODate + qso.TimeOn + qso.RSTR + qso.RSTS + qso.GridSquare + "" apiUrl := config.Clublog.URL data := url.Values{} data.Set("api", config.Clublog.API) data.Set("email", config.Clublog.EMail) data.Set("password", config.Clublog.Password) data.Set("callsign", config.Clublog.Callsign) data.Set("adif", QSOData) u, _ := url.ParseRequestURI(apiUrl) urlStr := u.String() client := &http.Client{} r, _ := http.NewRequest(http.MethodPost, urlStr, strings.NewReader(data.Encode())) // URL-encoded payload r.Header.Add("Content-Type", "application/x-www-form-urlencoded") resp, _ := client.Do(r) if http.StatusOK == 200 { fmt.Println("QSO Uploaded to Clublog") } else { fmt.Printf("Error uploading QSO to Clublog %v", resp.Status) } }