广告平台(总站长使用)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

hdl_wx_open.go 1.1 KiB

4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. package hdl
  2. import (
  3. "applet/app/utils"
  4. "encoding/xml"
  5. "fmt"
  6. "github.com/gin-gonic/gin"
  7. "io/ioutil"
  8. "net/http"
  9. )
  10. type ReqWxMessage struct {
  11. AppID string `xml:"AppId"`
  12. CreateTime int64 `xml:"CreateTime"`
  13. InfoType string `xml:"InfoType"`
  14. ComponentVerifyTicket string `xml:"ComponentVerifyTicket"`
  15. }
  16. func SetTicket(c *gin.Context) {
  17. query := c.Request.URL.Query()
  18. var params = map[string]string{}
  19. for key, value := range query {
  20. fmt.Printf("Key: %s, Value: %s\n", key, value[0])
  21. params[key] = value[0]
  22. }
  23. utils.FilePutContents("SetTicket_Get", utils.SerializeStr(params))
  24. var wxMsg ReqWxMessage
  25. // 读取请求体
  26. body, err := ioutil.ReadAll(c.Request.Body)
  27. if err != nil {
  28. c.JSON(http.StatusBadRequest, gin.H{"error": "failed to read request body"})
  29. return
  30. }
  31. err = xml.Unmarshal(body, &wxMsg)
  32. if err != nil {
  33. fmt.Println("setTicket>>>>>>>>", err.Error())
  34. c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
  35. return
  36. }
  37. utils.FilePutContents("SetTicket_XML", utils.SerializeStr(wxMsg))
  38. c.String(http.StatusOK, "success")
  39. return
  40. }
  41. func WechatMsgRecieve(c *gin.Context) {
  42. return
  43. }