标签:get word client https 认证 util func printf use
func main() { //生成client 参数为默认 client := &http.Client{} //生成要访问的url url := "https://api.XXXXX.com/v2/users/XXXX/behavior?$user_id=XXXX" //提交请求 reqest, err := http.NewRequest("GET", url, nil) reqest.SetBasicAuth("13XXXX493","congmXXXXXXXXX493")//设置需要认证的username和password if err != nil { panic(err) } //处理返回结果 response, _ := client.Do(reqest) defer response.Body.Close() body, err := ioutil.ReadAll(response.Body) fmt.Printf("%s\n",body) }
标签:get word client https 认证 util func printf use
原文地址:https://www.cnblogs.com/luffe/p/8797039.html