structure.go 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  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 int64 `xml:"CreateTime" json:"CreateTime"`
  64. MsgType string `xml:"MsgType" json:"MsgType"` // text/image/voice/video/shortvideo/location/link
  65. // 文本 Content Text message
  66. Content string `xml:"Content,omitempty" json:"Content,omitempty"`
  67. // 图片 PicURL / MediaID image messgae
  68. PicURL string `xml:"PicUrl,omitempty" json:"PicUrl,omitempty"`
  69. MediaID string `xml:"MediaId,omitempty" json:"MediaId,omitempty"`
  70. // 语音 MediaID / Format voice message
  71. Format string `xml:"Format,omitempty" json:"Format,omitempty"`
  72. // 视频/小视频 ThumbMediaID / MediaID video/shortvideo message
  73. ThumbMediaID string `xml:"ThumbMediaId,omitempty" json:"ThumbMediaId,omitempty"`
  74. // 地理位置 location message
  75. LocationX string `xml:"Location_X,omitempty" json:"Location_X,omitempty"` // 经度
  76. LocationY string `xml:"Location_Y,omitempty" json:"Location_Y,omitempty"` // 纬度
  77. Scale string `xml:"Scale,omitempty" json:"Scale,omitempty"` // 地图缩放大小
  78. Label string `xml:"Label,omitempty" json:"Label,omitempty"` // 地理位置信息
  79. // 链接消息 link
  80. Title string `xml:"Title,omitempty" json:"Title,omitempty"` // 消息标题
  81. Description string `xml:"Description,omitempty" json:"Description,omitempty"` // 消息描述
  82. URL string `xml:"Url,omitempty" json:"Url,omitempty"` // 消息链接
  83. Event string `xml:"Event,omitempty" json:"Event,omitempty"` // 事件 subscribe(订阅)、unsubscribe(取消订阅)
  84. MsgID int64 `xml:"MsgId,omitempty" json:"MsgId,omitempty"` // 消息id
  85. }
  86. // ArticleItem article item
  87. type ArticleItem struct {
  88. Title string `xml:"Title" json:"Title"`
  89. Description string `xml:"Description" json:"Description"`
  90. PicURL string `xml:"PicUrl" json:"PicUrl"`
  91. URL string `xml:"Url" json:"Url"`
  92. }
  93. type articleItems struct {
  94. Items []ArticleItem `xml:"item" json:"item"`
  95. }
  96. // ReplyMessage reply message
  97. type ReplyMessage struct {
  98. XMLName xml.Name `xml:"xml"`
  99. ToUserName string `xml:"ToUserName" json:"ToUserName"`
  100. FromUserName string `xml:"FromUserName" json:"FromUserName"`
  101. CreateTime int64 `xml:"CreateTime" json:"CreateTime"`
  102. MsgType string `xml:"MsgType" json:"MsgType"` // text/image/voice/video/music/news
  103. // 文本 Content Text message
  104. Content string `xml:"Content,omitempty" json:"Content,omitempty"`
  105. // image
  106. ArticleCount int `xml:"ArticleCount,omitempty" json:"ArticleCount,omitempty"`
  107. Articles *articleItems `xml:"Articles,omitempty" json:"Articles,omitempty"`
  108. }
  109. /*
  110. <xml>
  111. <ToUserName><![CDATA[toUser]]></ToUserName>
  112. <FromUserName><![CDATA[fromUser]]></FromUserName>
  113. <CreateTime>12345678</CreateTime>
  114. <MsgType><![CDATA[news]]></MsgType>
  115. <ArticleCount>1</ArticleCount>
  116. <Articles>
  117. <item>
  118. <Title><![CDATA[title1]]></Title>
  119. <Description><![CDATA[description1]]></Description>
  120. <PicUrl><![CDATA[picurl]]></PicUrl>
  121. <Url><![CDATA[url]]></Url>
  122. </item>
  123. </Articles>
  124. </xml>
  125. // */
  126. // EventTemplateReply event reply
  127. type EventTemplateReply struct {
  128. XMLName xml.Name `xml:"xml"`
  129. ToUserName string `xml:"ToUserName"`
  130. FromUserName string `xml:"FromUserName"`
  131. CreateTime string `xml:"CreateTime"`
  132. MsgType string `xml:"MsgType"`
  133. Event string `xml:"Event"`
  134. MsgID string `xml:"MsgID"`
  135. Status string `xml:"Status"`
  136. }
  137. // SignPackage sign package
  138. type SignPackage struct {
  139. AppID string `json:"appId"`
  140. NonceStr string `json:"nonceStr"`
  141. Timestamp int64 `json:"timestamp"`
  142. Signature string `json:"signature"`
  143. URL string `json:"url"`
  144. }
  145. // Client wechat
  146. type Client struct {
  147. AppID string `json:"appid"`
  148. AppSecret string `json:"appsecret"`
  149. Token string `json:"token"`
  150. EncodingAESKey string `json:"encodingaeskey"`
  151. AccessToken string
  152. LastTokenTime int64
  153. Ticket string
  154. LastTicketTime int64
  155. }
  156. // MiniClient wechat mini
  157. type MiniClient struct {
  158. AppID string `json:"appid"`
  159. AppSecret string `json:"appsecret"`
  160. AccessToken string
  161. LastTokenTime int64
  162. }
  163. // FormMaterial Material
  164. type FormMaterial struct {
  165. Type string `form:"type"`
  166. Offset int `form:"offset"`
  167. Count int `form:"count"`
  168. }
  169. // UserInfo userinfo
  170. type UserInfo struct {
  171. SubScribe int `json:"subscribe"`
  172. OpenID string `json:"openid"`
  173. NickName string `json:"nickname"`
  174. Sex int `json:"sex"`
  175. Language string `json:"language"`
  176. City string `json:"city"`
  177. Province string `json:"province"`
  178. Country string `json:"country"`
  179. HeadImgURL string `json:"headimgurl"`
  180. SubscribeTime int `json:"subscribe_time"`
  181. UnionID string `json:"unionid"`
  182. Remark string `json:"remark"`
  183. GroupID int `json:"groupid"`
  184. TagidList []int `json:"tagid_list"`
  185. SubscribeScene string `json:"subscribe_scene"`
  186. QrScene int `json:"qr_scene"`
  187. QrSceneStr string `json:"qr_scene_str"`
  188. }
  189. // List openid list
  190. type List struct {
  191. OpenID []string `json:"openid"`
  192. }
  193. // UserList user list
  194. type UserList struct {
  195. Total int `json:"total"`
  196. Count int `json:"count"`
  197. Data List `json:"data"`
  198. NextOpenID string `json:"next_openid"`
  199. }
  200. type newsitem struct {
  201. Title string `json:"title"`
  202. Author string `json:"author"`
  203. Digest string `json:"digest"`
  204. Content string `json:"content"`
  205. ContentSourceURL string `json:"content_source_url"`
  206. ThumbMediaID string `json:"thumb_media_id"`
  207. ShowCoverPic int `json:"show_cover_pic"`
  208. URL string `json:"url"`
  209. ThumbURL string `json:"thumb_url"`
  210. NeedOpenComment int `json:"need_open_comment"`
  211. OnlyFansCanComment int `json:"only_fans_can_comment"`
  212. }
  213. type content struct {
  214. NewsItem []*newsitem `json:"news_item,omitempty"`
  215. CreateTime int `json:"create_time,omitempty"`
  216. UpdateTime int `json:"update_time,omitempty"`
  217. }
  218. type item struct {
  219. MediaID string `json:"media_id"`
  220. Name string `json:"name,omitempty"`
  221. UpdateTime int `json:"update_time"`
  222. URL string `json:"url,omitempty"`
  223. Content *content `json:"content,omitempty"`
  224. }
  225. // Material 素材
  226. type Material struct {
  227. TotalCount int `json:"total_count"`
  228. ItemCount int `json:"item_count"`
  229. Item []item `json:"item"`
  230. }
  231. // MiniProgramPage mini
  232. type MiniProgramPage struct {
  233. AppID string `json:"appid,omitempty"`
  234. PagePath string `json:"pagepath,omitempty"`
  235. }
  236. // ValueColor value color
  237. type ValueColor struct {
  238. Value string `json:"value"`
  239. Color string `json:"color,omitempty"`
  240. }
  241. // TemplateData data
  242. type TemplateData struct {
  243. First *ValueColor `json:"first"`
  244. Keyword1 *ValueColor `json:"keyword1,omitempty"`
  245. Keyword2 *ValueColor `json:"keyword2,omitempty"`
  246. Keyword3 *ValueColor `json:"keyword3,omitempty"`
  247. Keyword4 *ValueColor `json:"keyword4,omitempty"`
  248. Keyword5 *ValueColor `json:"keyword5,omitempty"`
  249. Keyword6 *ValueColor `json:"keyword6,omitempty"`
  250. Keyword7 *ValueColor `json:"keyword7,omitempty"`
  251. Keyword8 *ValueColor `json:"keyword8,omitempty"`
  252. Keyword9 *ValueColor `json:"keyword9,omitempty"`
  253. Remark *ValueColor `json:"remark,omitempty"`
  254. }
  255. // TemplateMessage template message
  256. type TemplateMessage struct {
  257. ToUser string `json:"touser"`
  258. TemplateID string `json:"template_id"`
  259. URL string `json:"url"`
  260. MiniProgram *MiniProgramPage `json:"miniprogram,omitempty"`
  261. Data TemplateData `json:"data"`
  262. }
  263. // MiniTemplateMessage mini template message
  264. type MiniTemplateMessage struct {
  265. ToUser string `json:"touser"`
  266. TemplateID string `json:"template_id"`
  267. Page string `json:"page"`
  268. FormID string `json:"form_id"`
  269. Data TemplateData `json:"data"`
  270. }
  271. // WeappTemplateMessage mini message
  272. type WeappTemplateMessage struct {
  273. TemplateID string `json:"template_id"`
  274. Page string `json:"page"`
  275. FormID string `json:"form_id"`
  276. Data TemplateData `json:"data"`
  277. Emphasis string `json:"emphasis_keyword"`
  278. }
  279. // MpTemplateMessage wechat public message
  280. type MpTemplateMessage struct {
  281. AppID string `json:"appid"`
  282. TemplateID string `json:"template_id"`
  283. URL string `json:"url"`
  284. Mini MiniProgramPage `json:"miniprogram"`
  285. Data TemplateData `json:"data"`
  286. }
  287. // MiniUniformMessage mini uniform send
  288. type MiniUniformMessage struct {
  289. ToUser string `json:"touser"`
  290. WeApp *WeappTemplateMessage `json:"weapp_template_msg,omitempty"`
  291. MP *MpTemplateMessage `json:"mp_template_msg,omitempty"`
  292. }