123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359 |
- package wechat
- import "encoding/xml"
- // FormSignature signature
- type FormSignature struct {
- TimeStamp string `form:"timestamp" json:"timestamp"`
- Nonce string `form:"nonce" json:"nonce"`
- Signature string `form:"signature" json:"signature"`
- Echostr string `form:"echostr" json:"echostr"`
- }
- // FormAuthorize get code
- type FormAuthorize struct {
- Code string `form:"code"`
- State string `form:"state"`
- URL string `form:"url"`
- }
- // FormOpenID openid
- type FormOpenID struct {
- OpenID string `form:"openid"`
- }
- // FormCode code
- type FormCode struct {
- Code string `form:"code"`
- }
- // FormURLState redirect url and state
- type FormURLState struct {
- RedirectURL string `form:"url" json:"url" xml:"url"`
- State string `form:"state" json:"state" xml:"state"`
- }
- // ResponseMsg response
- type ResponseMsg struct {
- ErrCode int `json:"errcode"`
- ErrMsg string `json:"errmsg"`
- }
- /*
- // Response response
- type Response struct {
- ErrCode int `json:"errcode"`
- ErrMsg string `json:"errmsg"`
- // token
- AccessToken string `json:"access_token"`
- ExpiresIn int `json:"expires_in"`
- // openid
- RefreshToken string `json:"refresh_token"`
- OpenID string `json:"openid"`
- Scope string `json:"scope"`
- // user info
- NickName string `json:"nickname"`
- Sex string `json:"sex"`
- Province string `json:"province"`
- City string `json:"city"`
- Country string `json:"country"`
- HeadImgURL string `json:"headimgurl"`
- Privilege string `json:"privilege"`
- UnionID string `json:"unionid"`
- // template message
- MsgID int64 `json:"msgid"`
- // jsapi_ticket
- Ticket string `json:"ticket"`
- // mini get openid by code
- SessionKey string `json:"session_key"`
- }
- // */
- // Message message
- type Message struct {
- XMLName xml.Name `xml:"xml"`
- ToUserName string `xml:"ToUserName" json:"ToUserName"`
- FromUserName string `xml:"FromUserName" json:"FromUserName"`
- CreateTime int64 `xml:"CreateTime" json:"CreateTime"`
- MsgType string `xml:"MsgType" json:"MsgType"` // text/image/voice/video/shortvideo/location/link
- // 文本 Text Text message
- Text string `xml:"Content,omitempty" json:"Content,omitempty"`
- // 图片 PicURL / MediaID image messgae
- PicURL string `xml:"PicUrl,omitempty" json:"PicUrl,omitempty"`
- MediaID string `xml:"MediaId,omitempty" json:"MediaId,omitempty"`
- // 语音 MediaID / Format voice message
- Format string `xml:"Format,omitempty" json:"Format,omitempty"`
- // 视频/小视频 ThumbMediaID / MediaID video/shortvideo message
- ThumbMediaID string `xml:"ThumbMediaId,omitempty" json:"ThumbMediaId,omitempty"`
- // 地理位置 location message
- LocationX string `xml:"Location_X,omitempty" json:"Location_X,omitempty"` // 经度
- LocationY string `xml:"Location_Y,omitempty" json:"Location_Y,omitempty"` // 纬度
- Scale string `xml:"Scale,omitempty" json:"Scale,omitempty"` // 地图缩放大小
- Label string `xml:"Label,omitempty" json:"Label,omitempty"` // 地理位置信息
- // 链接消息 link
- Title string `xml:"Title,omitempty" json:"Title,omitempty"` // 消息标题
- Description string `xml:"Description,omitempty" json:"Description,omitempty"` // 消息描述
- URL string `xml:"Url,omitempty" json:"Url,omitempty"` // 消息链接
- Event string `xml:"Event,omitempty" json:"Event,omitempty"` // 事件 subscribe(订阅)、unsubscribe(取消订阅)、CLICK(自定义菜单事件)、SCAN
- // 扫描带参数二维码事件
- EventKey string `xml:"EventKey,omitempty" json:"EventKey,omitempty"` // 事件KEY 值,扫码未关注的 qrscene_ 为前缀(subscribe 事件, 已关注的推送 SCAN 事件),后面为二维码的参数值, 自定义菜单事件与自定义菜单接口中 KEY 值对应
- Ticket string `xml:"Ticket,omitempty" json:"Ticket,omitempty"` // 二维码的ticket,可用来换取二维码图片
- MsgID int64 `xml:"MsgId,omitempty" json:"MsgId,omitempty"` // 消息id
- }
- // ArticleItem article item
- type ArticleItem struct {
- Title string `xml:"Title" json:"Title"`
- Description string `xml:"Description" json:"Description"`
- PicURL string `xml:"PicUrl" json:"PicUrl"`
- URL string `xml:"Url" json:"Url"`
- }
- type articleItems struct {
- Items []ArticleItem `xml:"item" json:"item"`
- }
- // ReplyMessage reply message
- type ReplyMessage struct {
- XMLName xml.Name `xml:"xml"`
- ToUserName string `xml:"ToUserName" json:"ToUserName"`
- FromUserName string `xml:"FromUserName" json:"FromUserName"`
- CreateTime int64 `xml:"CreateTime" json:"CreateTime"`
- MsgType string `xml:"MsgType" json:"MsgType"` // text/image/voice/video/music/news
- // 文本 Content Text message
- Content string `xml:"Content,omitempty" json:"Content,omitempty"`
- // image
- ArticleCount int `xml:"ArticleCount,omitempty" json:"ArticleCount,omitempty"`
- Articles *articleItems `xml:"Articles,omitempty" json:"Articles,omitempty"`
- }
- /*
- <xml>
- <ToUserName><![CDATA[toUser]]></ToUserName>
- <FromUserName><![CDATA[fromUser]]></FromUserName>
- <CreateTime>12345678</CreateTime>
- <MsgType><![CDATA[news]]></MsgType>
- <ArticleCount>1</ArticleCount>
- <Articles>
- <item>
- <Title><![CDATA[title1]]></Title>
- <Description><![CDATA[description1]]></Description>
- <PicUrl><![CDATA[picurl]]></PicUrl>
- <Url><![CDATA[url]]></Url>
- </item>
- </Articles>
- </xml>
- // */
- // EventTemplateReply event reply
- type EventTemplateReply struct {
- XMLName xml.Name `xml:"xml"`
- ToUserName string `xml:"ToUserName"`
- FromUserName string `xml:"FromUserName"`
- CreateTime string `xml:"CreateTime"`
- MsgType string `xml:"MsgType"`
- Event string `xml:"Event"`
- MsgID string `xml:"MsgID"`
- Status string `xml:"Status"`
- }
- // SignPackage sign package
- type SignPackage struct {
- AppID string `json:"appId"`
- NonceStr string `json:"nonceStr"`
- Timestamp int64 `json:"timestamp"`
- Signature string `json:"signature"`
- URL string `json:"url"`
- }
- // Client wechat
- type Client struct {
- AppID string `json:"appid"`
- AppSecret string `json:"appsecret"`
- Token string `json:"token"`
- EncodingAESKey string `json:"encodingaeskey"`
- AccessToken string
- LastTokenTime int64
- Ticket string
- LastTicketTime int64
- }
- // MiniClient wechat mini
- type MiniClient struct {
- AppID string `json:"appid"`
- AppSecret string `json:"appsecret"`
- AccessToken string
- LastTokenTime int64
- }
- // FormMaterial Material
- type FormMaterial struct {
- Type string `form:"type"`
- Offset int `form:"offset"`
- Count int `form:"count"`
- }
- // UserInfo userinfo
- type UserInfo struct {
- SubScribe int `json:"subscribe"`
- OpenID string `json:"openid"`
- NickName string `json:"nickname"`
- Sex int `json:"sex"`
- Language string `json:"language"`
- City string `json:"city"`
- Province string `json:"province"`
- Country string `json:"country"`
- HeadImgURL string `json:"headimgurl"`
- SubscribeTime int `json:"subscribe_time"`
- UnionID string `json:"unionid"`
- Remark string `json:"remark"`
- GroupID int `json:"groupid"`
- TagidList []int `json:"tagid_list"`
- SubscribeScene string `json:"subscribe_scene"`
- QrScene int `json:"qr_scene"`
- QrSceneStr string `json:"qr_scene_str"`
- }
- // List openid list
- type List struct {
- OpenID []string `json:"openid"`
- }
- // UserList user list
- type UserList struct {
- Total int `json:"total"`
- Count int `json:"count"`
- Data List `json:"data"`
- NextOpenID string `json:"next_openid"`
- }
- // MaterialNewsItem 图片素材
- type MaterialNewsItem struct {
- Title string `json:"title"`
- Author string `json:"author"`
- Digest string `json:"digest"`
- Content string `json:"content"`
- ContentSourceURL string `json:"content_source_url"`
- ThumbMediaID string `json:"thumb_media_id"`
- ShowCoverPic int `json:"show_cover_pic"`
- URL string `json:"url"`
- ThumbURL string `json:"thumb_url"`
- NeedOpenComment int `json:"need_open_comment"`
- OnlyFansCanComment int `json:"only_fans_can_comment"`
- }
- // MaterialContent 素材内容
- type MaterialContent struct {
- NewsItem []*MaterialNewsItem `json:"news_item,omitempty"`
- CreateTime int `json:"create_time,omitempty"`
- UpdateTime int `json:"update_time,omitempty"`
- }
- // MaterialItem 素材信息
- type MaterialItem struct {
- MediaID string `json:"media_id"`
- Name string `json:"name,omitempty"`
- UpdateTime int `json:"update_time"`
- URL string `json:"url,omitempty"`
- Content *MaterialContent `json:"content,omitempty"`
- }
- // Material 素材
- type Material struct {
- TotalCount int `json:"total_count"`
- ItemCount int `json:"item_count"`
- Item []MaterialItem `json:"item"`
- }
- // MiniProgramPage mini
- type MiniProgramPage struct {
- AppID string `json:"appid,omitempty"`
- PagePath string `json:"pagepath,omitempty"`
- }
- // ValueColor value color
- type ValueColor struct {
- Value string `json:"value"`
- Color string `json:"color,omitempty"`
- }
- // TemplateData data
- type TemplateData struct {
- First *ValueColor `json:"first"`
- Keyword1 *ValueColor `json:"keyword1,omitempty"`
- Keyword2 *ValueColor `json:"keyword2,omitempty"`
- Keyword3 *ValueColor `json:"keyword3,omitempty"`
- Keyword4 *ValueColor `json:"keyword4,omitempty"`
- Keyword5 *ValueColor `json:"keyword5,omitempty"`
- Keyword6 *ValueColor `json:"keyword6,omitempty"`
- Keyword7 *ValueColor `json:"keyword7,omitempty"`
- Keyword8 *ValueColor `json:"keyword8,omitempty"`
- Keyword9 *ValueColor `json:"keyword9,omitempty"`
- Keyword10 *ValueColor `json:"keyword10,omitempty"`
- Name *ValueColor `json:"name,omitempty"`
- ExpDate *ValueColor `json:"expDate,omitempty"`
- Remark *ValueColor `json:"remark,omitempty"`
- }
- // TemplateMessage template message
- type TemplateMessage struct {
- ToUser string `json:"touser"`
- TemplateID string `json:"template_id"`
- URL string `json:"url"`
- MiniProgram *MiniProgramPage `json:"miniprogram,omitempty"`
- Data TemplateData `json:"data"`
- }
- // MiniTemplateMessage mini template message
- type MiniTemplateMessage struct {
- ToUser string `json:"touser"`
- TemplateID string `json:"template_id"`
- Page string `json:"page"`
- FormID string `json:"form_id"`
- Data TemplateData `json:"data"`
- }
- // WeappTemplateMessage mini message
- type WeappTemplateMessage struct {
- TemplateID string `json:"template_id"`
- Page string `json:"page"`
- FormID string `json:"form_id"`
- Data TemplateData `json:"data"`
- Emphasis string `json:"emphasis_keyword"`
- }
- // MpTemplateMessage wechat public message
- type MpTemplateMessage struct {
- AppID string `json:"appid"`
- TemplateID string `json:"template_id"`
- URL string `json:"url"`
- Mini MiniProgramPage `json:"miniprogram"`
- Data TemplateData `json:"data"`
- }
- // MiniUniformMessage mini uniform send
- type MiniUniformMessage struct {
- ToUser string `json:"touser"`
- WeApp *WeappTemplateMessage `json:"weapp_template_msg,omitempty"`
- MP *MpTemplateMessage `json:"mp_template_msg,omitempty"`
- }
|