mirror of
https://github.com/silenceper/wechat.git
synced 2026-02-04 12:52:27 +08:00
enc.SetEscapeHTML 支持版本>=1.7,使用简单替换 #15
This commit is contained in:
13
util/http.go
13
util/http.go
@@ -27,16 +27,17 @@ func HTTPGet(uri string) ([]byte, error) {
|
||||
|
||||
//PostJSON post json 数据请求
|
||||
func PostJSON(uri string, obj interface{}) ([]byte, error) {
|
||||
jsonBuf := new(bytes.Buffer)
|
||||
enc := json.NewEncoder(jsonBuf)
|
||||
enc.SetEscapeHTML(false)
|
||||
err := enc.Encode(obj)
|
||||
|
||||
jsonData, err := json.Marshal(obj)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
response, err := http.Post(uri, "application/json;charset=utf-8", jsonBuf)
|
||||
jsonData = bytes.Replace(jsonData, []byte("\\u003c"), []byte("<"), -1)
|
||||
jsonData = bytes.Replace(jsonData, []byte("\\u003e"), []byte(">"), -1)
|
||||
jsonData = bytes.Replace(jsonData, []byte("\\u0026"), []byte("&"), -1)
|
||||
|
||||
body := bytes.NewBuffer(jsonData)
|
||||
response, err := http.Post(uri, "application/json;charset=utf-8", body)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user