package controllers import ( "git.rosy.net.cn/baseapi/utils" "git.rosy.net.cn/jx-callback/globals" "io/ioutil" "net/http" "git.rosy.net.cn/jx-callback/globals/api" "github.com/astaxie/beego/server/web" ) type WeixinController struct { web.Controller } func (c *WeixinController) Msg() { if c.Ctx.Input.Method() == http.MethodGet { signature := c.GetString("signature") timestamp := c.GetString("timestamp") nonce := c.GetString("nonce") echostr := c.GetString("echostr") isValid := api.WeixinAPI.ValidateWXCallbackURL(signature, timestamp, nonce) globals.SugarLogger.Debugf("isvaild %s", utils.Format4Output(isValid, false)) c.Ctx.WriteString(echostr) } else { c.Data["json"] = "ok" c.ServeJSON() } } func (c *WeixinController) WifiMsg() { data, _ := ioutil.ReadAll(c.Ctx.Request.Body) values, _ := utils.HTTPBody2Values(data, false) mapData := utils.URLValues2Map(values) globals.SugarLogger.Debugf("mapData %s", utils.Format4Output(mapData, false)) c.Data["json"] = "ok" c.ServeJSON() }