Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

72 lines
1.0KB

  1. //analyze xml message
  2. package main
  3. import (
  4. "encoding/xml"
  5. )
  6. //all xml message has these headers
  7. type CommonHeader struct {
  8. ToUserName string
  9. FromUserName string
  10. CreateTime int64
  11. MsgType string
  12. }
  13. //text message
  14. type TextMsg struct {
  15. Content string
  16. MsgId int64
  17. }
  18. //picture
  19. type PicMsg struct {
  20. PicUrl string
  21. MeidaId string
  22. MsgId int64
  23. }
  24. //voice
  25. type VoiceMsg struct {
  26. MeidaId string
  27. Format string
  28. MsgId int64
  29. }
  30. //video
  31. type VideoMsg struct {
  32. MediaId string
  33. ThumbMediaId string
  34. MsgId int64
  35. }
  36. //short video
  37. type ShortVideo struct {
  38. MeidaId string
  39. ThumbMediaId string
  40. MsgId int64
  41. }
  42. //Location Info
  43. type Location struct {
  44. Location_X float64
  45. Location_Y float64
  46. Scale int
  47. Label string
  48. MsgId int64
  49. }
  50. type LinkMsg struct {
  51. Title string
  52. Description string
  53. Url string
  54. MsgId int64
  55. }
  56. //ReadCommonHeader parse xml of common field of wechat post message
  57. func ReadCommonHeader(s string) CommonHeader {
  58. var r = CommonHeader{}
  59. xml.Unmarshal([]byte(s), &r)
  60. return r
  61. }