client.go 511 B

12345678910111213141516171819202122
  1. package main
  2. import (
  3. "fmt"
  4. "log"
  5. "net/http"
  6. "strings"
  7. )
  8. func BindUserWithWX(url, contentType, body string) (*http.Response, error) {
  9. // body := `{"userinfo":"tmr.shengmu23.bbc","openid":"123"}`
  10. // url :="http://kpttest.kptyun.com/userwxopenid/binding"
  11. // contentType:="application/json"
  12. resp, err := http.Post(url, contentType, strings.NewReader(body))
  13. if err != nil {
  14. log.Default().Printf("%+v\n", err)
  15. return nil, err
  16. }
  17. defer resp.Body.Close()
  18. fmt.Printf("%+v\n", resp)
  19. return resp, nil
  20. }