| // | // | ||||
| func answerWechatPost(w http.ResponseWriter, r *http.Request) { | func answerWechatPost(w http.ResponseWriter, r *http.Request) { | ||||
| body, _ := ioutil.ReadAll(r.Body) | body, _ := ioutil.ReadAll(r.Body) | ||||
| fmt.Printf("get body: %s", string(body)) | |||||
| //fmt.Printf("get body: %s", string(body)) | |||||
| s := ReadEncryptedMsg(string(body)) | s := ReadEncryptedMsg(string(body)) | ||||
| //fmt.Printf("to decrypt %s", s.Encrypt) | //fmt.Printf("to decrypt %s", s.Encrypt) | ||||
| d := Decode(s.Encrypt) | d := Decode(s.Encrypt) | ||||
| fmt.Printf("decrypt as: %s", d) | |||||
| //fmt.Printf("decrypt as: %s", d) | |||||
| h := ReadCommonHeader(d) | h := ReadCommonHeader(d) | ||||
| reply, _ := BuildTextMsg(h.MsgType, h.FromUserName) | reply, _ := BuildTextMsg(h.MsgType, h.FromUserName) | ||||
| fmt.Fprint(w, reply) | fmt.Fprint(w, reply) |