diff --git a/const.go b/const.go index 1ee3735..9d9f3a8 100644 --- a/const.go +++ b/const.go @@ -3,5 +3,5 @@ package wechatopen const ( apiUrl = "https://api.weixin.qq.com" logTable = "wechatopen" - Version = "1.0.25" + Version = "1.0.26" ) diff --git a/service_http.gin.go b/service_http.gin.go index 099c348..dc8dc75 100644 --- a/service_http.gin.go +++ b/service_http.gin.go @@ -7,13 +7,13 @@ import ( // ResponseServeHttpGin 推送信息 type ResponseServeHttpGin struct { - MsgSignature string `form:"msg_signature" json:"msg_signature" xml:"msg_signature" uri:"msg_signature" binding:"omitempty"` // 签名串,对应 URL 参数的msg_signature - Timestamp string `form:"timestamp" json:"timestamp" xml:"timestamp" uri:"timestamp" binding:"omitempty"` // 时间戳,对应 URL 参数的timestamp - Nonce string `form:"nonce" json:"nonce" xml:"nonce" uri:"nonce" binding:"omitempty"` // 随机串,对应 URL 参数的nonce - Signature string `form:"signature" json:"signature" xml:"signature" uri:"signature" binding:"omitempty"` - EncryptType string `form:"encrypt_type" json:"encrypt_type" xml:"encrypt_type" uri:"encrypt_type" binding:"omitempty"` // 加密类型 - AppId string `form:"AppId" json:"AppId" xml:"AppId" uri:"AppId" binding:"omitempty"` // 第三方平台 appid - Encrypt string `form:"Encrypt" json:"Encrypt" xml:"Encrypt" uri:"Encrypt" binding:"omitempty"` // 加密内容 + MsgSignature string // 签名串,对应 URL 参数的msg_signature + Timestamp string // 时间戳,对应 URL 参数的timestamp + Nonce string // 随机串,对应 URL 参数的nonce + Signature string + EncryptType string // 加密类型 + AppId string // 第三方平台 appid + Encrypt string // 加密内容 } // ServeHttpGin 验证票据推送 diff --git a/sign.decrypt.go b/sign.decrypt.go index d90900a..2f20a91 100644 --- a/sign.decrypt.go +++ b/sign.decrypt.go @@ -9,18 +9,13 @@ import ( "strings" ) -type SignDecryptParams struct { - Signature string `json:"signature"` - Timestamp string `json:"timestamp"` - Nonce string `json:"nonce"` - EncryptType string `json:"encrypt_type"` - MsgSignature string `json:"msg_signature"` - AppId string `json:"app_id"` - Encrypt string `json:"encrypt"` -} - // SignDecrypt 解密 -func (c *Client) SignDecrypt(ctx context.Context, params SignDecryptParams, strXml interface{}) ([]byte, error) { +// ctx 上下文 +// params 入参 +// strXml 反射结构体 +// resp 加密数据 +// err 错误信息 +func (c *Client) SignDecrypt(ctx context.Context, params SignDecryptParams, strXml interface{}) (resp []byte, err error) { if params.Signature == "" { return nil, errors.New("找不到签名参数") diff --git a/sign.decrypt.params.go b/sign.decrypt.params.go new file mode 100644 index 0000000..99117b8 --- /dev/null +++ b/sign.decrypt.params.go @@ -0,0 +1,12 @@ +package wechatopen + +// SignDecryptParams 入参 +type SignDecryptParams struct { + Signature string // 签名串,对应 URL 参数的msg_signature + Timestamp string // 时间戳,对应 URL 参数的timestamp + Nonce string // 随机串,对应 URL 参数的nonce + EncryptType string // 加密类型 + MsgSignature string + AppId string // 第三方平台 appid + Encrypt string // 加密内容 +} diff --git a/sign.decrypt.response.go b/sign.decrypt.response.go new file mode 100644 index 0000000..cd067d1 --- /dev/null +++ b/sign.decrypt.response.go @@ -0,0 +1,116 @@ +package wechatopen + +import "encoding/xml" + +// SignDecryptComponentVerifyTicket 验证票据 +// https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/Before_Develop/component_verify_ticket.html +type SignDecryptComponentVerifyTicket struct { + XMLName xml.Name + AppId string `xml:"appId,omitempty"` // 第三方平台 appid + CreateTime int64 `xml:"CreateTime,omitempty"` // 时间戳,单位:s + InfoType string `xml:"InfoType,omitempty"` // 固定为:"component_verify_ticket" + ComponentVerifyTicket string `xml:"ComponentVerifyTicket,omitempty"` // Ticket 内容 +} + +// SignDecryptAuthorizeEvent 授权变更通知推送 +// https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/Before_Develop/authorize_event.html +type SignDecryptAuthorizeEvent struct { + XMLName xml.Name + AppId string `xml:"appId,omitempty"` // 第三方平台 appid + CreateTime int64 `xml:"CreateTime,omitempty"` // 时间戳,单位:s + InfoType string `xml:"InfoType,omitempty"` // 通知类型 unauthorized=取消授权 updateauthorized=更新授权 authorized=授权成功 + AuthorizerAppid string `xml:"AuthorizerAppid,omitempty"` // 公众号或小程序的 appid + AuthorizationCode string `xml:"AuthorizationCode,omitempty"` // 授权码,可用于获取授权信息 + AuthorizationCodeExpiredTime string `xml:"AuthorizationCodeExpiredTime,omitempty"` // 授权码过期时间 单位秒 + PreAuthCode string `xml:"PreAuthCode,omitempty"` // 预授权码 +} + +// SignDecryptNotifyThirdFasteRegister 快速注册企业/个人小程序 +// https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/Register_Mini_Programs/Fast_Registration_Interface_document.html +// https://developers.weixin.qq.com/doc/oplatform/openApi/OpenApiDoc/register-management/fast-registration-ind/fastRegisterPersonalMp.html +type SignDecryptNotifyThirdFasteRegister struct { + XMLName xml.Name + AppId string `xml:"AppId,omitempty"` // 第三方平台 appid + CreateTime int64 `xml:"CreateTime,omitempty"` // 时间戳,单位:s + InfoType string `xml:"InfoType,omitempty"` // 类型 + Appid string `xml:"appid,omitempty"` // 创建小程序appid + Status int64 `xml:"status,omitempty"` // 状态 + AuthCode string `xml:"auth_code,omitempty"` // 第三方授权码 + Msg string `xml:"msg,omitempty"` // 信息 + Info struct { + Name string `xml:"name,omitempty"` // 企业名称 + Code string `xml:"code,omitempty"` // 企业代码 + CodeType string `xml:"code_type,omitempty"` + LegalPersonaWechat string `xml:"legal_persona_wechat,omitempty"` // (企业)法人微信号 + LegalPersonaName string `xml:"legal_persona_name,omitempty"` // (企业)法人姓名 + ComponentPhone string `xml:"component_phone,omitempty"` // (企业/个人)第三方联系电话 + Wxuser string `xml:"wxuser"` // (个人)用户微信号 + Idname string `xml:"idname"` // (个人)用户姓名 + } `xml:"info,omitempty"` +} + +// SignDecryptNotifyThirdFastRegisterBetaApp 注册试用小程序 +// https://developers.weixin.qq.com/doc/oplatform/openApi/OpenApiDoc/register-management/fast-regist-beta/registerBetaMiniprogram.html +type SignDecryptNotifyThirdFastRegisterBetaApp struct { + XMLName xml.Name + AppId string `xml:"AppId,omitempty"` // 第三方平台 appid + CreateTime int64 `xml:"CreateTime,omitempty"` // 时间戳,单位:s + InfoType string `xml:"InfoType,omitempty"` // 类型 + Appid string `xml:"appid,omitempty"` // 创建小程序appid + Status int64 `xml:"status,omitempty"` // 状态 + Msg string `xml:"msg,omitempty"` // 信息 + Info struct { + UniqueId string `xml:"unique_id,omitempty"` + Name string `xml:"name,omitempty"` // 小程序名称 + } `xml:"info,omitempty"` +} + +// SignDecryptNotifyThirdFastVerifyBetaApp 试用小程序快速认证 +// https://developers.weixin.qq.com/doc/oplatform/openApi/OpenApiDoc/register-management/fast-regist-beta/verfifyBetaMiniprogram.html +type SignDecryptNotifyThirdFastVerifyBetaApp struct { + XMLName xml.Name + AppId string `xml:"AppId,omitempty"` // 第三方平台 appid + CreateTime int64 `xml:"CreateTime,omitempty"` // 时间戳,单位:s + InfoType string `xml:"InfoType,omitempty"` // 类型 + Appid string `xml:"appid,omitempty"` // 创建小程序appid + Status int64 `xml:"status,omitempty"` // 状态 + Msg string `xml:"msg,omitempty"` // 信息 + Info struct { + Name string `xml:"name,omitempty"` // 企业名称 + Code string `xml:"code,omitempty"` // 企业代码 + CodeType string `xml:"code_type,omitempty"` + LegalPersonaWechat string `xml:"legal_persona_wechat,omitempty"` // 法人微信号 + LegalPersonaName string `xml:"legal_persona_name,omitempty"` // 法人姓名 + ComponentPhone string `xml:"component_phone,omitempty"` // 第三方联系电话 + } `xml:"info,omitempty"` +} + +// SignDecryptWxaNicknameAudit 名称审核结果事件推送 +// https://developers.weixin.qq.com/doc/oplatform/openApi/OpenApiDoc/miniprogram-management/basic-info-management/setNickName.html +type SignDecryptWxaNicknameAudit struct { + XMLName xml.Name + ToUserName string `xml:"ToUserName,omitempty"` // 小程序的原始 ID + FromUserName string `xml:"FromUserName,omitempty"` // 发送方帐号(一个 OpenID,此时发送方是系统帐号) + CreateTime int64 `xml:"CreateTime,omitempty"` // 消息创建时间 (整型),时间戳 + MsgType string `xml:"MsgType,omitempty"` // 消息类型 event + Event string `xml:"Event,omitempty"` // 事件类型 + Ret string `xml:"ret,omitempty"` // 审核结果 2:失败,3:成功 + Nickname string `xml:"nickname,omitempty"` // 需要更改的昵称 + Reason string `xml:"reason,omitempty"` // 审核失败的驳回原因 +} + +// SignDecryptWeAppAudit 代码审核结果推送 +// https://developers.weixin.qq.com/doc/oplatform/openApi/OpenApiDoc/miniprogram-management/code-management/submitAudit.html +type SignDecryptWeAppAudit struct { + XMLName xml.Name + ToUserName string `xml:"ToUserName,omitempty"` // 小程序的原始 ID + FromUserName string `xml:"FromUserName,omitempty"` // 发送方帐号(一个 OpenID,此时发送方是系统帐号) + CreateTime int64 `xml:"CreateTime,omitempty"` // 消息创建时间 (整型),时间戳 + MsgType string `xml:"MsgType,omitempty"` // 消息类型 event + Event string `xml:"Event,omitempty"` // 事件类型 weapp_audit_success=审核通过 weapp_audit_fail=审核不通过 weapp_audit_delay=审核延后 + SuccTime int64 `xml:"SuccTime,omitempty"` // 审核成功时的时间戳 + FailTime int64 `xml:"FailTime,omitempty"` // 审核不通过的时间戳 + DelayTime int64 `xml:"DelayTime,omitempty"` // 审核延后时的时间戳 + Reason string `xml:"reason,omitempty"` // 审核不通过的原因 + ScreenShot string `xml:"ScreenShot,omitempty"` // 审核不通过的截图示例。用 | 分隔的 media_id 的列表,可通过获取永久素材接口拉取截图内容 +}