| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423 | package wechatimport (	"encoding/xml")// Client wechattype Client struct {	AppID          string `json:"appid"`	AppSecret      string `json:"appsecret"`	Token          string `json:"token"`	EncodingAESKey string `json:"encodingaeskey"`	//ReadLock *sync.Mutex	AccessToken   string	LastTokenTime int64	Ticket         string	LastTicketTime int64}// MiniClient wechat minitype MiniClient struct {	AppID     string `json:"appid"`	AppSecret string `json:"appsecret"`	AccessToken   string	LastTokenTime int64}// FormSignature signaturetype 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 codetype FormAuthorize struct {	Code  string `form:"code"`	State string `form:"state"`	URL   string `form:"url"`}// FormOpenID openidtype FormOpenID struct {	OpenID string `form:"openid"`}// FormCode codetype FormCode struct {	Code string `form:"code"`}// FormSignPackage js sign packagetype FormSignPackage struct {	URL string `form:"url"`}// FormURLState redirect url and statetype FormURLState struct {	RedirectURL string `form:"url" json:"url" xml:"url"`	State       string `form:"state" json:"state" xml:"state"`}// ResponseMsg responsetype ResponseMsg struct {	ErrCode int    `json:"errcode"`	ErrMsg  string `json:"errmsg"`}/*// Response responsetype 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 messagetype 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 媒体	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,可用来换取二维码图片	// 地理位置 location message	Latitude  string `xml:"Latitude,omitempty" json:"Latitude,omitempty"`   // 纬度	Longitude string `xml:"Longitude,omitempty" json:"Longitude,omitempty"` // 经度	Precision string `xml:"Precision,omitempty" json:"Precision,omitempty"` // 地理位置精度	MsgID  int64  `xml:"MsgID,omitempty" json:"MsgID,omitempty"`   // 消息id	Status string `xml:"Status,omitempty" json:"Status,omitempty"` // 消息发送状态}type menuSubButtonList struct {	Type string `json:"type"`	Name string `json:"name"`	Key  string `json:"key"`	URL  string `json:"url"`}type menuSubButton struct {	List []menuSubButtonList `json:"list"`}type menuButton struct {	Type      string        `json:"type"`	Name      string        `json:"name"`	Key       string        `json:"key"`	SubButton menuSubButton `json:"sub_button"`}type menuInfo struct {	Button []menuButton `json:"button"`}// Menu menutype Menu struct {	IsOpen int64    `json:"is_menu_open"`	Info   menuInfo `json:"selfmenu_info"`}type formMenuButton struct {	Type      string            `json:"type,omitempty"`	Name      string            `json:"name"`	Key       string            `json:"key,omitempty"`	URL       string            `json:"url,omitempty"`	AppID     string            `json:"appid,omitempty"`	Pagepath  string            `json:"pagepath,omitempty"`	MediaID   string            `json:"media_id,omitempty"`	SubButton []*formMenuButton `json:"sub_button,omitempty"`}// FormMenu menu createtype FormMenu struct {	Button []*formMenuButton `json:"button"`}// ArticleItem article itemtype 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 messagetype 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 replytype 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 packagetype SignPackage struct {	AppID     string `json:"appId"`	NonceStr  string `json:"nonceStr"`	Timestamp int64  `json:"timestamp"`	Signature string `json:"signature"`	Ticket    string `json:"ticket"`	URL       string `json:"url"`}// FormMaterial Materialtype FormMaterial struct {	Type   string `form:"type"`	Offset int    `form:"offset"`	Count  int    `form:"count"`}// UserInfo userinfotype 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"`}// FormNextOpenID next openidtype FormNextOpenID struct {	Next string `form:"next_openid"`}// List openid listtype List struct {	OpenID []string `json:"openid"`}// UserList user listtype 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 minitype MiniProgramPage struct {	AppID    string `json:"appid,omitempty"`	PagePath string `json:"pagepath,omitempty"`}// ValueColor value colortype ValueColor struct {	Value string `json:"value"`	Color string `json:"color,omitempty"`}// TemplateData datatype 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 messagetype 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 messagetype 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 messagetype 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 messagetype 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 sendtype MiniUniformMessage struct {	ToUser string                `json:"touser"`	WeApp  *WeappTemplateMessage `json:"weapp_template_msg,omitempty"`	MP     *MpTemplateMessage    `json:"mp_template_msg,omitempty"`}
 |