123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179 |
- package wechat_service
-
- import (
- "encoding/xml"
- "time"
-
- "github.com/silenceper/wechat/menu"
- )
-
- //MsgEncrypt 微信平台向第三方平台授权事件接收URL推送的xml数据结构
- type MsgEncrypt struct {
- AppID string `xml:"AppId"`
- Encrypt string `xml:"Encrypt"`
- }
-
- //ComponentRequestBody 第三方平台授权事件接收URL接收数据后解密后的基本结构,
- //有各种不同的结构:Ticket,AuthorizedStruct,UnauthorizedStruct,UpdateauthorizedStruct,由InfoType.InfoType判断
- type ComponentRequestBody struct {
- AppID string `xml:"AppId"`
- CreateTime string `xml:"CreateTime"`
- InfoType string `xml:"InfoType"`
-
- // 接收微信平台向第三方平台授权事件接收URL推送,InfoType为component_verify_ticket时,返回
- ComponentVerifyTicket string `xml:"ComponentVerifyTicket,omitempty"`
-
- // 微信平台向第三方平台授权事件接收URL推送的数据,InfoType为authorized,unauthorized,updateauthorized时间有返回
- AuthorizerAppid string `xml:"AuthorizerAppid,omitempty"`
-
- // 微信平台向第三方平台授权事件接收URL推送的数据,InfoType为authorized,updateauthorized时间有返回
- AuthorizationCode string `xml:"AuthorizationCode,omitempty"`
- AuthorizationCodeExpiredTime string `xml:"AuthorizationCodeExpiredTime,omitempty"`
- PreAuthCode string `xml:"PreAuthCode,omitempty"`
- }
-
- type EncryptRequestBody struct {
- XMLName xml.Name `xml:"xml"`
- ToUserName string
- Encrypt string
- }
-
- type TextRequestBody struct {
- XMLName xml.Name `xml:"xml"`
- ToUserName string
- FromUserName string
- CreateTime time.Duration
- MsgType string
- Event string
- EventKey string
- Url string
- PicUrl string
- MediaId string
- ThumbMediaId string
- Content string
- MsgId int
- Location_X string
- Location_Y string
- Label string
- }
- type CDATAText struct {
- Text string `xml:",innerxml"`
- }
-
- type EncryptResponseBody struct {
- XMLName xml.Name `xml:"xml"`
- Encrypt CDATAText
- MsgSignature CDATAText
- TimeStamp string
- Nonce CDATAText
- }
-
- type TextResponseBody struct {
- XMLName xml.Name `xml:"xml"`
- ToUserName CDATAText
- FromUserName CDATAText
- CreateTime string
- MsgType CDATAText
- Content CDATAText
- }
-
- type MPResult struct {
- ErrCode int64 `json:"errcode"`
- ErrMsg string `json:"errmsg"`
- }
-
- //ResAddMaterial 永久性素材上传返回的结果
- type ResAddMaterial struct {
- MPResult
-
- MediaID string `json:"media_id"`
- URL string `json:"url"`
- }
-
- //ComponentAccessToken 第三方平台主动向微信服务器请求第三方平台自己的component_access_token返回的数据结构
- type ComponentAccessToken struct {
- ComponentAccessToken string `json:"component_access_token"`
- ExpiresIn int `json:"expires_in"`
- }
-
- //PreAuthCode 第三方平台主动向微信服务器请求第三方平台预授权码pre_auth_code返回的数据结构
- type PreAuthCode struct {
- PreAuthCode string `json:"pre_auth_code"`
- ExpiresIn int `json:"expires_in"`
- }
-
- //AuthorizationInfo 公众号向第三方平台授权成功后,在redirect_uri利用auth_code(公众号确定授权后,微信拼接在redirect_uri上,用来交换AuthorizationInfo)主动请求授权信息
- type AuthorizationInfo struct {
- AuthorizationInfo struct {
- AuthorizerAppid string `json:"authorizer_appid"`
- AuthorizerAccessToken string `json:"authorizer_access_token"`
- ExpiresIn int64 `json:"expires_in"`
- AuthorizerRefreshToken string `json:"authorizer_refresh_token"`
- FuncInfo []FuncInfoItems `json:"func_info"`
- } `json:"authorization_info"`
- }
-
- type FuncInfoItems struct {
- FuncscopeCategory struct {
- ID int64 `json:"id"`
- } `json:"funcscope_category"`
- }
-
- //AuthorizerInfo 第三方平利用authorizer_appid(公众号的appid,授权确定后获得,AuthorizationInfo.authorizer_appid)和component_appid(第三方平台appid,在微信开发平台新建一个第三方应用时生成)
- type AuthorizerInfo struct {
- AuthorizerInfo struct {
- NickName string `json:"nick_name"`
- HeadImg string `json:"head_img"`
- ServiceTypeInfo AuthorizerInfoTypeInfo `json:"service_type_info"`
- VerifyTypeInfo AuthorizerInfoTypeInfo `json:"verify_type_info"`
- UserName string `json:"user_name"`
- QrcodeURL string `json:"qrcode_url"`
- PrincipalName string `json:"principal_name"`
- BusinessInfo BusinessInfo `json:"business_info"`
- FuncInfo []FuncInfoItems `json:"func_info"`
- } `json:"authorizer_info"`
- }
-
- type AuthorizerInfoTypeInfo struct {
- ID int64 `json:"id"`
- }
-
- type BusinessInfo struct {
- OpenPay int64 `json:"open_pay"`
- OpenShake int64 `json:"open_shake"`
- OpenScan int64 `json:"open_scan"`
- OpenCard int64 `json:"open_card"`
- OpenStore int64 `json:"open_store"`
- }
-
- //微信菜单形式
- type SelfMenuInfo struct {
- Button []SelfMenuButton `json:"button"`
- }
-
- //reqMenu 设置菜单请求数据
- type RRreqMenu struct {
- Button []*menu.Button `json:"button,omitempty"`
- MatchRule *menu.MatchRule `json:"matchrule,omitempty"`
- }
-
- //SelfMenuButton 自定义菜单配置详情
- type SelfMenuButton struct {
- Name string `json:"name"`
- Type string `json:"type,omitempty"`
- Key string `json:"key,omitempty"`
- AppID string `json:"appid,omitempty"`
- PagePath string `json:"pagepath,omitempty"`
- Message string `json:"message,omitempty"`
- URL string `json:"url,omitempty"`
- MediaId string `json:"media_id,omitempty"`
- MediaUrl string `json:"media_url,omitempty"`
- SubButton []SelfMenuButton `json:"sub_button,omitempty"`
- }
-
- type RefreshToken struct {
- AuthorizerAccessToken string `json:"authorizer_access_token"`
- ExpiresIn int64 `json:"expires_in"`
- AuthorizerRefreshToken string `json:"authorizer_refresh_token"`
- }
|