Documentation
¶
Overview ¶
获取授权方的帐号基本信息 - 公众号 - 小程序
Index ¶
- Constants
- Variables
- func DecodeMessage(msgSignature, timeStamp, nonce string, body []byte) (t wx_open.Message, err error)
- func DecodeMessageByte(msgSignature, timeStamp, nonce string, body []byte) (bs []byte, err error)
- func EncodeMessageByte(body []byte) (bs []byte, err error)
- func FilterReady(appId string, body []byte) (stop bool, response []byte, err error)
- func GetComponentAccessToken() (componentAccessToken string, err error)
- func GetLastVerifyTicket() (ticket string, ok bool)
- func GetPreAuthCode() (preAuthCode string, err error)
- func HandleComponentVerifyTicketReq(bs []byte) (ticket string, err error)
- func HandleEvent(bs []byte, handler EventHandler) (rsp []byte, err error)
- func HandleMessage(bs []byte, appId string, filterReady bool, handler EventHandler) (rsp []byte, err error)
- func InitThirdParty(token, aeskey, appid, appSecret string)
- func SaveVerifyTicket(ticket string) (err error)
- type AuthMsgCancelAuthReq
- type AuthMsgComponentVerifyTicketReq
- type AuthorizedInfoReq
- type AuthorizedInfoRsp
- type AuthorizerInfo
- type AuthorizerTokenReq
- type AuthorizerTokenRsp
- type ComponentAccessTokenReq
- type ComponentAccessTokenRsp
- type EventHandler
- type EventReq
- type MessageHandler
- type MessageReq
- type PreAuthCodeReq
- type PreAuthCodeRsp
- type SavedVerifyTicket
- type WxAppInfo
Constants ¶
View Source
const ( URLComponentToken = "https://api.weixin.qq.com/cgi-bin/component/api_component_token" URLPreAuthCode = "https://api.weixin.qq.com/cgi-bin/component/api_create_preauthcode?component_access_token=" // 公众号或小程序的接口调用凭据 URLOtherAuthToken = "https://api.weixin.qq.com/cgi-bin/component/api_query_auth?component_access_token=" // 获取(刷新)授权公众号或小程序的接口调用凭据(令牌) URLRefreshOtherAuthToken = "https://api.weixin.qq.com/cgi-bin/component/api_authorizer_token?component_access_token=" )
Variables ¶
View Source
var ( Token string AesKey string AppId string AppSecret string )
Functions ¶
func DecodeMessage ¶
func DecodeMessage(msgSignature, timeStamp, nonce string, body []byte) (t wx_open.Message, err error)
解密消息/事件推送
func DecodeMessageByte ¶
解密消息/事件推送
func FilterReady ¶
拦截测试消息并相应
func GetComponentAccessToken ¶
获取ComponentAccessToken 会检测过期时间自动刷新哟
func GetPreAuthCode ¶
获取PreAuthCode 会检测过期时间自动刷新哟
func HandleComponentVerifyTicketReq ¶
处理微信VerifyTicket回调 成功后会将ticket保存在本地文件
func HandleMessage ¶
func HandleMessage(bs []byte, appId string, filterReady bool, handler EventHandler) (rsp []byte, err error)
处理公众号消息 filterReady: 是否处理全网发布的测试消息
func InitThirdParty ¶
func InitThirdParty(token, aeskey, appid, appSecret string)
在调用第三方平台的时候请务必Init
Types ¶
type AuthMsgCancelAuthReq ¶
type AuthMsgCancelAuthReq struct { EventReq CreateTime string `xml:"CreateTime"` AuthorizerAppid string `xml:"AuthorizerAppid"` }
取消授权通知
type AuthMsgComponentVerifyTicketReq ¶
type AuthMsgComponentVerifyTicketReq struct { AppId string `xml:"AppId"` CreateTime string `xml:"CreateTime"` InfoType string `xml:"InfoType"` ComponentVerifyTicket string `xml:"ComponentVerifyTicket"` AuthorizationCode string `xml:"AuthorizationCode"` }
component_verify_ticket 出于安全考虑,在第三方平台创建审核通过后,微信服务器每隔10分钟会向第三方的消息接收地址推送一次component_verify_ticket,用于获取第三方平台接口调用凭据 接收到后必须直接返回字符串success。
type AuthorizedInfoReq ¶
type AuthorizedInfoRsp ¶
type AuthorizedInfoRsp struct { wx_open.WxResponse AccessToken string `json:"authorizer_access_token"` ExpiresIn int64 `json:"expires_in"` RefreshToken string `json:"authorizer_refresh_token"` }
func RefreshAccessToken ¶
func RefreshAccessToken(authorizerAppid, refreshToken string) (authorizedInfo *AuthorizedInfoRsp, err error)
type AuthorizerInfo ¶
type AuthorizerInfo struct { UserName string `json:"user_name"` // 小程序的原始ID HeadImg string `json:"head_img"` // 授权方头像 NickName string `json:"nick_name"` // 授权方昵称 PrincipalName string `json:"principal_name"` // 小程序的主体名称 Signature string `json:"signature"` // 帐号介绍 QrcodeUrl string `json:"qrcode_url"` // 二维码图片的URL,开发者最好自行也进行保存 VerifyTypeInfo struct { Id int `json:"id"` } `json:"verify_type_info"` // 授权方认证类型,-1代表未认证,0代表微信认证 MiniProgramInfo struct { Network struct { RequestDomain []string `json:"RequestDomain"` WsRequestDomain []string `json:"WsRequestDomain"` UploadDomain []string `json:"UploadDomain"` DownloadDomain []string `json:"DownloadDomain"` } `json:"network"` } `json:"MiniProgramInfo"` BusinessInfo struct { OpenPay int `json:"open_pay"` // 是否开通微信支付功能 OpenShake int `json:"open_shake"` // 是否开通微信摇一摇功能 OpenScan int `json:"open_scan"` // 是否开通微信扫商品功能 OpenCard int `json:"open_card"` // 是否开通微信卡券功能 OpenStore int `json:"open_store"` // 是否开通微信门店功能 } `json:"business_info"` }
type AuthorizerTokenReq ¶
type AuthorizerTokenRsp ¶
type AuthorizerTokenRsp 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 []struct { FuncscopeCategory struct { Id int `json:"id"` } `json:"funcscope_category"` } `json:"func_info"` } `json:"authorization_info"` }
func GetAuthorizerToken ¶
func GetAuthorizerToken(authorizationCode string) (authorizerTokenRsp *AuthorizerTokenRsp, err error)
type ComponentAccessTokenReq ¶
type ComponentAccessTokenRsp ¶
type MessageReq ¶
type MessageReq struct {
MsgType string `xml:"MsgType"` // 消息类型: event, text ....
}
初步解析body, 得到type
type PreAuthCodeReq ¶
type PreAuthCodeReq struct {
ComponentAppid string `json:"component_appid"`
}
type PreAuthCodeRsp ¶
type SavedVerifyTicket ¶
type WxAppInfo ¶
type WxAppInfo struct { wx_open.WxResponse AuthorizerInfo AuthorizerInfo `json:"authorizer_info"` }
Click to show internal directories.
Click to hide internal directories.