structure.go 7.4 KB

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