structure.go 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. package wechat
  2. import "encoding/xml"
  3. // FormSignature signature
  4. type FormSignature struct {
  5. TimeStamp string `form:"timestamp" json:"timestamp"`
  6. Nonce string `form:"nonce" json:"nonce"`
  7. Signature string `form:"signature" json:"signature"`
  8. Echostr string `form:"echostr" json:"echostr"`
  9. }
  10. // FormAuthorize get code
  11. type FormAuthorize struct {
  12. Code string `form:"code"`
  13. State string `form:"state"`
  14. URL string `form:"url"`
  15. }
  16. // FormOpenID openid
  17. type FormOpenID struct {
  18. OpenID string `form:"openid"`
  19. }
  20. // FormCode code
  21. type FormCode struct {
  22. Code string `form:"code"`
  23. }
  24. // ResponseMsg response
  25. type ResponseMsg struct {
  26. ErrCode int `json:"errcode"`
  27. ErrMsg string `json:"errmsg"`
  28. }
  29. // Response response
  30. type Response struct {
  31. ErrCode int `json:"errcode"`
  32. ErrMsg string `json:"errmsg"`
  33. // token
  34. AccessToken string `json:"access_token"`
  35. ExpiresIn int `json:"expires_in"`
  36. // openid
  37. RefreshToken string `json:"refresh_token"`
  38. OpenID string `json:"openid"`
  39. Scope string `json:"scope"`
  40. // user info
  41. NickName string `json:"nickname"`
  42. Sex string `json:"sex"`
  43. Province string `json:"province"`
  44. City string `json:"city"`
  45. Country string `json:"country"`
  46. HeadImgURL string `json:"headimgurl"`
  47. Privilege string `json:"privilege"`
  48. UnionID string `json:"unionid"`
  49. // template message
  50. MsgID int64 `json:"msgid"`
  51. // jsapi_ticket
  52. Ticket string `json:"ticket"`
  53. // mini get openid by code
  54. SessionKey string `json:"session_key"`
  55. }
  56. // Message message
  57. type Message struct {
  58. XMLName xml.Name `xml:"xml"`
  59. ToUserName string `xml:"ToUserName" json:"ToUserName"`
  60. FromUserName string `xml:"FromUserName" json:"FromUserName"`
  61. CreateTime int32 `xml:"CreateTime" json:"CreateTime"`
  62. MsgType string `xml:"MsgType" json:"MsgType"`
  63. MsgID int64 `xml:"MsgId" json:"MsgId"`
  64. }
  65. // EventTemplateReply event reply
  66. type EventTemplateReply struct {
  67. XMLName xml.Name `xml:"xml"`
  68. ToUserName string `xml:"ToUserName"`
  69. FromUserName string `xml:"FromUserName"`
  70. CreateTime string `xml:"CreateTime"`
  71. MsgType string `xml:"MsgType"`
  72. Event string `xml:"Event"`
  73. MsgID string `xml:"MsgID"`
  74. Status string `xml:"Status"`
  75. }
  76. // SignPackage sign package
  77. type SignPackage struct {
  78. AppID string `json:"appId"`
  79. NonceStr string `json:"nonceStr"`
  80. Timestamp int64 `json:"timestamp"`
  81. Signature string `json:"signature"`
  82. URL string `json:"url"`
  83. }
  84. // Client wechat
  85. type Client struct {
  86. AppID string `json:"appid"`
  87. AppSecret string `json:"appsecret"`
  88. Token string `json:"token"`
  89. EncodingAESKey string `json:"encodingaeskey"`
  90. AccessToken string
  91. LastTokenTime int64
  92. Ticket string
  93. LastTicketTime int64
  94. }
  95. // MiniClient wechat mini
  96. type MiniClient struct {
  97. AppID string `json:"appid"`
  98. AppSecret string `json:"appsecret"`
  99. AccessToken string
  100. LastTokenTime int64
  101. }
  102. // FormMaterial Material
  103. type FormMaterial struct {
  104. Type string `form:"type"`
  105. Offset int `form:"offset"`
  106. Count int `form:"count"`
  107. }
  108. // UserInfo userinfo
  109. type UserInfo struct {
  110. SubScribe int `json:"subscribe"`
  111. OpenID string `json:"openid"`
  112. NickName string `json:"nickname"`
  113. Sex int `json:"sex"`
  114. Language string `json:"language"`
  115. City string `json:"city"`
  116. Province string `json:"province"`
  117. Country string `json:"country"`
  118. HeadImgURL string `json:"headimgurl"`
  119. SubscribeTime int `json:"subscribe_time"`
  120. UnionID string `json:"unionid"`
  121. Remark string `json:"remark"`
  122. GroupID int `json:"groupid"`
  123. TagidList []int `json:"tagid_list"`
  124. SubscribeScene string `json:"subscribe_scene"`
  125. QrScene int `json:"qr_scene"`
  126. QrSceneStr string `json:"qr_scene_str"`
  127. }
  128. // List openid list
  129. type List struct {
  130. OpenID []string `json:"openid"`
  131. }
  132. // UserList user list
  133. type UserList struct {
  134. Total int `json:"total"`
  135. Count int `json:"count"`
  136. Data List `json:"data"`
  137. NextOpenID string `json:"next_openid"`
  138. }
  139. type newsitem struct {
  140. Title string `json:"title"`
  141. Author string `json:"author"`
  142. Digest string `json:"digest"`
  143. Content string `json:"content"`
  144. ContentSourceURL string `json:"content_source_url"`
  145. ThumbMediaID string `json:"thumb_media_id"`
  146. ShowCoverPic int `json:"show_cover_pic"`
  147. URL string `json:"url"`
  148. ThumbURL string `json:"thumb_url"`
  149. NeedOpenComment int `json:"need_open_comment"`
  150. OnlyFansCanComment int `json:"only_fans_can_comment"`
  151. }
  152. type content struct {
  153. NewsItem []*newsitem `json:"news_item,omitempty"`
  154. CreateTime int `json:"create_time,omitempty"`
  155. UpdateTime int `json:"update_time,omitempty"`
  156. }
  157. type item struct {
  158. MediaID string `json:"media_id"`
  159. Name string `json:"name,omitempty"`
  160. UpdateTime int `json:"update_time"`
  161. URL string `json:"url,omitempty"`
  162. Content *content `json:"content,omitempty"`
  163. }
  164. // Material 素材
  165. type Material struct {
  166. TotalCount int `json:"total_count"`
  167. ItemCount int `json:"item_count"`
  168. Item []item `json:"item"`
  169. }
  170. // MiniProgramPage mini
  171. type MiniProgramPage struct {
  172. AppID string `json:"appid,omitempty"`
  173. PagePath string `json:"pagepath,omitempty"`
  174. }
  175. // ValueColor value color
  176. type ValueColor struct {
  177. Value string `json:"value"`
  178. Color string `json:"color,omitempty"`
  179. }
  180. // TemplateData data
  181. type TemplateData struct {
  182. First *ValueColor `json:"first"`
  183. Keyword1 *ValueColor `json:"keyword1,omitempty"`
  184. Keyword2 *ValueColor `json:"keyword2,omitempty"`
  185. Keyword3 *ValueColor `json:"keyword3,omitempty"`
  186. Keyword4 *ValueColor `json:"keyword4,omitempty"`
  187. Keyword5 *ValueColor `json:"keyword5,omitempty"`
  188. Keyword6 *ValueColor `json:"keyword6,omitempty"`
  189. Keyword7 *ValueColor `json:"keyword7,omitempty"`
  190. Keyword8 *ValueColor `json:"keyword8,omitempty"`
  191. Keyword9 *ValueColor `json:"keyword9,omitempty"`
  192. Remark *ValueColor `json:"remark,omitempty"`
  193. }
  194. // TemplateMessage template message
  195. type TemplateMessage struct {
  196. ToUser string `json:"touser"`
  197. TemplateID string `json:"template_id"`
  198. URL string `json:"url"`
  199. MiniProgram *MiniProgramPage `json:"miniprogram,omitempty"`
  200. Data TemplateData `json:"data"`
  201. }
  202. // MiniTemplateMessage mini template message
  203. type MiniTemplateMessage struct {
  204. ToUser string `json:"touser"`
  205. TemplateID string `json:"template_id"`
  206. Page string `json:"page"`
  207. FormID string `json:"form_id"`
  208. Data TemplateData `json:"data"`
  209. }
  210. // WeappTemplateMessage mini message
  211. type WeappTemplateMessage struct {
  212. TemplateID string `json:"template_id"`
  213. Page string `json:"page"`
  214. FormID string `json:"form_id"`
  215. Data TemplateData `json:"data"`
  216. Emphasis string `json:"emphasis_keyword"`
  217. }
  218. // MpTemplateMessage wechat public message
  219. type MpTemplateMessage struct {
  220. AppID string `json:"appid"`
  221. TemplateID string `json:"template_id"`
  222. URL string `json:"url"`
  223. Mini MiniProgramPage `json:"miniprogram"`
  224. Data TemplateData `json:"data"`
  225. }
  226. // MiniUniformMessage mini uniform send
  227. type MiniUniformMessage struct {
  228. ToUser string `json:"touser"`
  229. WeApp *WeappTemplateMessage `json:"weapp_template_msg,omitempty"`
  230. MP *MpTemplateMessage `json:"mp_template_msg,omitempty"`
  231. }