- 微信公众号消息相关的消息回调
This commit is contained in:
28
controllers/weixin_callback.go
Normal file
28
controllers/weixin_callback.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"git.rosy.net.cn/jx-callback/globals/api"
|
||||
"github.com/astaxie/beego"
|
||||
)
|
||||
|
||||
type WeixinController struct {
|
||||
beego.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("weixin URL check is:%t", isValid)
|
||||
c.Ctx.WriteString(echostr)
|
||||
} else {
|
||||
c.Data["json"] = "ok"
|
||||
c.ServeJSON()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user