|
|
|
@@ -26,8 +26,8 @@ func apiV1Main(w http.ResponseWriter, r *http.Request) { |
|
|
|
|
|
|
|
switch r.Method { |
|
|
|
case "POST": |
|
|
|
answerWechatPostEcho(w, r) |
|
|
|
//answerWechatPost(w, r) |
|
|
|
//answerWechatPostEcho(w, r) |
|
|
|
answerWechatPost(w, r) |
|
|
|
case "GET": |
|
|
|
answerInitialAuth(w, r) |
|
|
|
default: |
|
|
|
@@ -55,11 +55,8 @@ func answerInitialAuth(w http.ResponseWriter, r *http.Request) { |
|
|
|
// |
|
|
|
func answerWechatPost(w http.ResponseWriter, r *http.Request) { |
|
|
|
body, _ := ioutil.ReadAll(r.Body) |
|
|
|
//fmt.Printf("get body: %s", string(body)) |
|
|
|
s := ReadEncryptedMsg(string(body)) |
|
|
|
//fmt.Printf("to decrypt %s", s.Encrypt) |
|
|
|
d := Decode(s.Encrypt) |
|
|
|
fmt.Printf("decrypt as: %s", d) |
|
|
|
d := decryptToXML(string(body)) |
|
|
|
fmt.Printf("decrypt as: %s\n", d) |
|
|
|
h := ReadCommonHeader(d) |
|
|
|
reply, _ := BuildTextMsg(h.MsgType, h.FromUserName) |
|
|
|
if h.MsgType == "voice" { |