PHP
·
发表于 5年以前
·
阅读量:8296
func httpPost() {
resp, err := http.Post("http://www.codingsky.com/demo/accept.php","application/x-www-form-urlencoded",strings.NewReader("id=123&token=abcabcabc"))
if err != nil {
fmt.Println(err)
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
// handle error
}
fmt.Println(string(body))
}
第二个参数要设置成”application/x-www-form-urlencoded”,否则post参数无法传递