Commit a764050e by 朱继来

调整json

parent 3808dcb6
...@@ -11,8 +11,8 @@ import ( ...@@ -11,8 +11,8 @@ import (
) )
type JosnResp struct { type JosnResp struct {
err_code string `json:"err_code"` Errcode int `json:"err_code"`
msg string `json:"msg"` Errmsg string `json:"msg"`
} }
func SendPurchaseEmail(data string) (err error) { func SendPurchaseEmail(data string) (err error) {
...@@ -20,9 +20,7 @@ func SendPurchaseEmail(data string) (err error) { ...@@ -20,9 +20,7 @@ func SendPurchaseEmail(data string) (err error) {
client := &http.Client{} client := &http.Client{}
byte, _ := json.Marshal(data) req, _ := http.NewRequest("POST", crm_url, strings.NewReader(string(data)))
req, _ := http.NewRequest("POST", crm_url, strings.NewReader(string(byte)))
req.Header.Set("api-key", "crm a1b2c3d4e5f6g7h8i9jk") req.Header.Set("api-key", "crm a1b2c3d4e5f6g7h8i9jk")
req.Header.Set("Content-Type", "application/json") req.Header.Set("Content-Type", "application/json")
...@@ -36,10 +34,10 @@ func SendPurchaseEmail(data string) (err error) { ...@@ -36,10 +34,10 @@ func SendPurchaseEmail(data string) (err error) {
} }
body, _ := ioutil.ReadAll(resp.Body) body, _ := ioutil.ReadAll(resp.Body)
fmt.Println(string(body))
res := &JosnResp{}
err1 := json.Unmarshal(body, res) res := JosnResp{}
err1 := json.Unmarshal([]byte(body), &res)
if err1 !=nil{ if err1 !=nil{
fmt.Println(err1) fmt.Println(err1)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment