From 321a6d5b00554ff40d1c7dd24dce5f133cac1688 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=85=89=E6=98=A5?= Date: Fri, 17 Jun 2022 15:42:46 +0800 Subject: [PATCH] - update --- cgi-bin.account.getaccountbasicinfo.go | 4 +- cgi-bin.component.api_authorizer_token.go | 12 +-- cgi-bin.component.api_component_token.go | 12 +-- cgi-bin.component.api_create_preauthcode.go | 8 +- cgi-bin.component.api_get_authorizer_info.go | 10 +- cgi-bin.component.api_query_auth.go | 10 +- cgi-bin.component.api_start_push_ticket.go | 10 +- cgi-bin.component.getprivacysetting.go | 4 +- cgi-bin.component.setprivacysetting.go | 6 +- cgi-bin.get_api_domain_ip.go | 4 +- cgi-bin.shorturl.go | 4 +- cgi-bin.wxopen.qrcodejumpadd.go | 6 +- cgi-bin.wxopen.qrcodejumpdelete.go | 4 +- cgi-bin.wxopen.qrcodejumpdownloa.go | 4 +- cgi-bin.wxopen.qrcodejumpget.go | 4 +- cgi-bin.wxopen.qrcodejumppublish.go | 4 +- get.go | 4 +- pgsql.go => log.go | 4 +- params.go | 2 +- redis.go | 96 ++++++++++---------- save_img.go | 2 +- service_http.authorizer_appid.go | 4 +- service_http.verify_ticket.go | 6 +- set.go | 4 +- sns.component.jscode2session.go | 14 +-- version.go | 2 +- wechatopen.go | 89 +++++++++--------- wxa.addtotemplate.go | 4 +- wxa.bind_tester.go | 4 +- wxa.business.getuserphonenumber.go | 4 +- wxa.commit.go | 4 +- wxa.deletetemplate.go | 4 +- wxa.get_auditstatus.go | 6 +- wxa.get_category.go | 4 +- wxa.get_effective_domain.go | 6 +- wxa.get_latest_auditstatus.go | 4 +- wxa.get_page.go | 4 +- wxa.get_qrcode.go | 4 +- wxa.gettemplatedraftlist.go | 4 +- wxa.gettemplatelist.go | 4 +- wxa.getversioninfo.go | 6 +- wxa.getwxacodeunlimit.go | 6 +- wxa.memberauth.go | 6 +- wxa.modify_domain.go | 6 +- wxa.modify_domain_directly.go | 6 +- wxa.release.go | 4 +- wxa.security.apply_privacy_interface.go | 6 +- wxa.security.get_privacy_interface.go | 4 +- wxa.submit_audit.go | 6 +- wxa.unbind_tester.go | 4 +- 50 files changed, 224 insertions(+), 219 deletions(-) rename pgsql.go => log.go (93%) diff --git a/cgi-bin.account.getaccountbasicinfo.go b/cgi-bin.account.getaccountbasicinfo.go index b287813..f0b29d5 100644 --- a/cgi-bin.account.getaccountbasicinfo.go +++ b/cgi-bin.account.getaccountbasicinfo.go @@ -55,9 +55,9 @@ func NewCgiBinAccountGetAccountBasicInfoResult(result CgiBinAccountGetAccountBas // CgiBinAccountGetAccountBasicInfo 获取基本信息 // https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/Mini_Program_Basic_Info/Mini_Program_Information_Settings.html -func (app *App) CgiBinAccountGetAccountBasicInfo() *CgiBinAccountGetAccountBasicInfoResult { +func (c *Client) CgiBinAccountGetAccountBasicInfo() *CgiBinAccountGetAccountBasicInfoResult { // 请求 - request, err := app.request(fmt.Sprintf("https://api.weixin.qq.com/cgi-bin/account/getaccountbasicinfo?access_token=%v", app.GetAuthorizerAccessToken()), map[string]interface{}{}, http.MethodGet) + request, err := c.request(fmt.Sprintf("https://api.weixin.qq.com/cgi-bin/account/getaccountbasicinfo?access_token=%v", c.GetAuthorizerAccessToken()), map[string]interface{}{}, http.MethodGet) // 定义 var response CgiBinAccountGetAccountBasicInfoResponse err = json.Unmarshal(request.ResponseBody, &response) diff --git a/cgi-bin.component.api_authorizer_token.go b/cgi-bin.component.api_authorizer_token.go index a22752c..e6c6d89 100644 --- a/cgi-bin.component.api_authorizer_token.go +++ b/cgi-bin.component.api_authorizer_token.go @@ -27,17 +27,17 @@ func NewCgiBinComponentApiAuthorizerTokenResult(result CgiBinComponentApiAuthori // CgiBinComponentApiAuthorizerToken 获取/刷新接口调用令牌 // https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/ThirdParty/token/api_authorizer_token.html -func (app *App) CgiBinComponentApiAuthorizerToken(authorizerRefreshToken string) *CgiBinComponentApiAuthorizerTokenResult { +func (c *Client) CgiBinComponentApiAuthorizerToken(authorizerRefreshToken string) *CgiBinComponentApiAuthorizerTokenResult { // 参数 param := NewParams() - param["component_appid"] = app.componentAppId // 第三方平台 appid - param["authorizer_appid"] = app.authorizerAppid // 授权方 appid + param["component_appid"] = c.config.ComponentAppId // 第三方平台 appid + param["authorizer_appid"] = c.config.AuthorizerAppid // 授权方 appid param["authorizer_refresh_token"] = authorizerRefreshToken // 授权码, 会在授权成功时返回给第三方平台 - params := app.NewParamsWith(param) + params := c.NewParamsWith(param) // 请求 - request, err := app.request(fmt.Sprintf("https://api.weixin.qq.com/cgi-bin/component/api_authorizer_token?component_access_token=%v", app.GetComponentAccessToken()), params, http.MethodPost) + request, err := c.request(fmt.Sprintf("https://api.weixin.qq.com/cgi-bin/component/api_authorizer_token?component_access_token=%v", c.GetComponentAccessToken()), params, http.MethodPost) // 定义 var response CgiBinComponentApiAuthorizerTokenResponse err = json.Unmarshal(request.ResponseBody, &response) - return NewCgiBinComponentApiAuthorizerTokenResult(response, request.ResponseBody, request, err, app.authorizerAppid) + return NewCgiBinComponentApiAuthorizerTokenResult(response, request.ResponseBody, request, err, c.config.AuthorizerAppid) } diff --git a/cgi-bin.component.api_component_token.go b/cgi-bin.component.api_component_token.go index 5ecba91..394e12e 100644 --- a/cgi-bin.component.api_component_token.go +++ b/cgi-bin.component.api_component_token.go @@ -24,15 +24,15 @@ func NewCgiBinComponentApiComponentTokenResult(result CgiBinComponentApiComponen // CgiBinComponentApiComponentToken 令牌 // https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/ThirdParty/token/component_access_token.html -func (app *App) CgiBinComponentApiComponentToken() *CgiBinComponentApiComponentTokenResult { +func (c *Client) CgiBinComponentApiComponentToken() *CgiBinComponentApiComponentTokenResult { // 参数 param := NewParams() - param["component_appid"] = app.componentAppId // 第三方平台 appid - param["component_appsecret"] = app.componentAppSecret // 第三方平台 appsecret - param["component_verify_ticket"] = app.GetComponentVerifyTicket() // 微信后台推送的 ticket - params := app.NewParamsWith(param) + param["component_appid"] = c.config.ComponentAppId // 第三方平台 appid + param["component_appsecret"] = c.config.ComponentAppSecret // 第三方平台 appsecret + param["component_verify_ticket"] = c.GetComponentVerifyTicket() // 微信后台推送的 ticket + params := c.NewParamsWith(param) // 请求 - request, err := app.request("https://api.weixin.qq.com/cgi-bin/component/api_component_token", params, http.MethodPost) + request, err := c.request("https://api.weixin.qq.com/cgi-bin/component/api_component_token", params, http.MethodPost) // 定义 var response CgiBinComponentApiComponentTokenResponse err = json.Unmarshal(request.ResponseBody, &response) diff --git a/cgi-bin.component.api_create_preauthcode.go b/cgi-bin.component.api_create_preauthcode.go index c217181..ef472d1 100644 --- a/cgi-bin.component.api_create_preauthcode.go +++ b/cgi-bin.component.api_create_preauthcode.go @@ -25,13 +25,13 @@ func NewCgiBinComponentApiCreatePreAuthCodenResult(result CgiBinComponentApiCrea // CgiBinComponentApiCreatePreAuthCoden 预授权码 // https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/ThirdParty/token/pre_auth_code.html -func (app *App) CgiBinComponentApiCreatePreAuthCoden() *CgiBinComponentApiCreatePreAuthCodenResult { +func (c *Client) CgiBinComponentApiCreatePreAuthCoden() *CgiBinComponentApiCreatePreAuthCodenResult { // 参数 param := NewParams() - param["component_appid"] = app.componentAppId // 第三方平台 appid - params := app.NewParamsWith(param) + param["component_appid"] = c.config.ComponentAppId // 第三方平台 appid + params := c.NewParamsWith(param) // 请求 - request, err := app.request(fmt.Sprintf("https://api.weixin.qq.com/cgi-bin/component/api_create_preauthcode?component_access_token=%v", app.GetComponentAccessToken()), params, http.MethodPost) + request, err := c.request(fmt.Sprintf("https://api.weixin.qq.com/cgi-bin/component/api_create_preauthcode?component_access_token=%v", c.GetComponentAccessToken()), params, http.MethodPost) // 定义 var response CgiBinComponentApiCreatePreAuthCodenResponse err = json.Unmarshal(request.ResponseBody, &response) diff --git a/cgi-bin.component.api_get_authorizer_info.go b/cgi-bin.component.api_get_authorizer_info.go index b7183e8..0a30e47 100644 --- a/cgi-bin.component.api_get_authorizer_info.go +++ b/cgi-bin.component.api_get_authorizer_info.go @@ -83,14 +83,14 @@ func NewCgiBinComponentApiGetAuthorizerInfoResult(result CgiBinComponentApiGetAu // CgiBinComponentApiGetAuthorizerInfo 获取授权帐号详情 // https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/ThirdParty/token/api_get_authorizer_info.html -func (app *App) CgiBinComponentApiGetAuthorizerInfo() *CgiBinComponentApiGetAuthorizerInfoResult { +func (c *Client) CgiBinComponentApiGetAuthorizerInfo() *CgiBinComponentApiGetAuthorizerInfoResult { // 参数 param := NewParams() - param["component_appid"] = app.componentAppId // 第三方平台 appid - param["authorizer_appid"] = app.authorizerAppid // 授权方 appid - params := app.NewParamsWith(param) + param["component_appid"] = c.config.ComponentAppId // 第三方平台 appid + param["authorizer_appid"] = c.config.AuthorizerAppid // 授权方 appid + params := c.NewParamsWith(param) // 请求 - request, err := app.request(fmt.Sprintf("https://api.weixin.qq.com/cgi-bin/component/api_get_authorizer_info?component_access_token=%v", app.GetComponentAccessToken()), params, http.MethodPost) + request, err := c.request(fmt.Sprintf("https://api.weixin.qq.com/cgi-bin/component/api_get_authorizer_info?component_access_token=%v", c.GetComponentAccessToken()), params, http.MethodPost) // 定义 var response CgiBinComponentApiGetAuthorizerInfoResponse err = json.Unmarshal(request.ResponseBody, &response) diff --git a/cgi-bin.component.api_query_auth.go b/cgi-bin.component.api_query_auth.go index b29e293..471e844 100644 --- a/cgi-bin.component.api_query_auth.go +++ b/cgi-bin.component.api_query_auth.go @@ -39,14 +39,14 @@ func NewCgiBinComponentApiQueryAuthResult(result CgiBinComponentApiQueryAuthResp // CgiBinComponentApiQueryAuth 使用授权码获取授权信息 // https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/ThirdParty/token/authorization_info.html -func (app *App) CgiBinComponentApiQueryAuth(authorizationCode string) *CgiBinComponentApiQueryAuthResult { +func (c *Client) CgiBinComponentApiQueryAuth(authorizationCode string) *CgiBinComponentApiQueryAuthResult { // 参数 param := NewParams() - param["component_appid"] = app.componentAppId // 第三方平台 appid - param["authorization_code"] = authorizationCode // 授权码, 会在授权成功时返回给第三方平台 - params := app.NewParamsWith(param) + param["component_appid"] = c.config.ComponentAppId // 第三方平台 appid + param["authorization_code"] = authorizationCode // 授权码, 会在授权成功时返回给第三方平台 + params := c.NewParamsWith(param) // 请求 - request, err := app.request(fmt.Sprintf("https://api.weixin.qq.com/cgi-bin/component/api_query_auth?component_access_token=%v", app.GetComponentAccessToken()), params, http.MethodPost) + request, err := c.request(fmt.Sprintf("https://api.weixin.qq.com/cgi-bin/component/api_query_auth?component_access_token=%v", c.GetComponentAccessToken()), params, http.MethodPost) // 定义 var response CgiBinComponentApiQueryAuthResponse err = json.Unmarshal(request.ResponseBody, &response) diff --git a/cgi-bin.component.api_start_push_ticket.go b/cgi-bin.component.api_start_push_ticket.go index 9aad174..806b815 100644 --- a/cgi-bin.component.api_start_push_ticket.go +++ b/cgi-bin.component.api_start_push_ticket.go @@ -26,14 +26,14 @@ func NewCgiBinComponentApiStartPushTicketResult(result CgiBinComponentApiStartPu // CgiBinComponentApiStartPushTicket 启动ticket推送服务 // https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/ThirdParty/token/component_verify_ticket_service.html -func (app *App) CgiBinComponentApiStartPushTicket() *CgiBinComponentApiStartPushTicketResult { +func (c *Client) CgiBinComponentApiStartPushTicket() *CgiBinComponentApiStartPushTicketResult { // 参数 param := NewParams() - param["component_appid"] = app.componentAppId // 平台型第三方平台的appid - param["component_secret"] = app.componentAppSecret // 平台型第三方平台的APPSECRET - params := app.NewParamsWith(param) + param["component_appid"] = c.config.ComponentAppId // 平台型第三方平台的appid + param["component_secret"] = c.config.ComponentAppSecret // 平台型第三方平台的APPSECRET + params := c.NewParamsWith(param) // 请求 - request, err := app.request("https://api.weixin.qq.com/cgi-bin/component/api_start_push_ticket", params, http.MethodPost) + request, err := c.request("https://api.weixin.qq.com/cgi-bin/component/api_start_push_ticket", params, http.MethodPost) // 定义 var response CgiBinComponentApiStartPushTicketResponse err = json.Unmarshal(request.ResponseBody, &response) diff --git a/cgi-bin.component.getprivacysetting.go b/cgi-bin.component.getprivacysetting.go index d79b99b..84109da 100644 --- a/cgi-bin.component.getprivacysetting.go +++ b/cgi-bin.component.getprivacysetting.go @@ -58,12 +58,12 @@ func NewCgiBinComponentGetPrivacySettingResult(result CgiBinComponentGetPrivacyS // CgiBinComponentGetPrivacySetting 查询小程序用户隐私保护指引 // @privacyVer 1表示现网版本,即,传1则该接口返回的内容是现网版本的;2表示开发版,即,传2则该接口返回的内容是开发版本的。默认是2。 // https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/privacy_config/get_privacy_setting.html -func (app *App) CgiBinComponentGetPrivacySetting(privacyVer int) *CgiBinComponentGetPrivacySettingResult { +func (c *Client) CgiBinComponentGetPrivacySetting(privacyVer int) *CgiBinComponentGetPrivacySettingResult { // 参数 params := NewParams() params["privacy_ver"] = privacyVer // 请求 - request, err := app.request(fmt.Sprintf("https://api.weixin.qq.com/cgi-bin/component/getprivacysetting?access_token=%s", app.GetAuthorizerAccessToken()), params, http.MethodPost) + request, err := c.request(fmt.Sprintf("https://api.weixin.qq.com/cgi-bin/component/getprivacysetting?access_token=%s", c.GetAuthorizerAccessToken()), params, http.MethodPost) // 定义 var response CgiBinComponentGetPrivacySettingResponse err = json.Unmarshal(request.ResponseBody, &response) diff --git a/cgi-bin.component.setprivacysetting.go b/cgi-bin.component.setprivacysetting.go index 4ff290e..343aa94 100644 --- a/cgi-bin.component.setprivacysetting.go +++ b/cgi-bin.component.setprivacysetting.go @@ -25,11 +25,11 @@ func NewCgiBinComponentSetPrivacySettingResult(result CgiBinComponentSetPrivacyS // CgiBinComponentSetPrivacySetting 配置小程序用户隐私保护指引 // https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/privacy_config/set_privacy_setting.html -func (app *App) CgiBinComponentSetPrivacySetting(notMustParams ...Params) *CgiBinComponentSetPrivacySettingResult { +func (c *Client) CgiBinComponentSetPrivacySetting(notMustParams ...Params) *CgiBinComponentSetPrivacySettingResult { // 参数 - params := app.NewParamsWith(notMustParams...) + params := c.NewParamsWith(notMustParams...) // 请求 - request, err := app.request(fmt.Sprintf("https://api.weixin.qq.com/cgi-bin/component/setprivacysetting?access_token=%s", app.GetAuthorizerAccessToken()), params, http.MethodPost) + request, err := c.request(fmt.Sprintf("https://api.weixin.qq.com/cgi-bin/component/setprivacysetting?access_token=%s", c.GetAuthorizerAccessToken()), params, http.MethodPost) // 定义 var response CgiBinComponentSetPrivacySettingResponse err = json.Unmarshal(request.ResponseBody, &response) diff --git a/cgi-bin.get_api_domain_ip.go b/cgi-bin.get_api_domain_ip.go index ebc1cd8..29d4168 100644 --- a/cgi-bin.get_api_domain_ip.go +++ b/cgi-bin.get_api_domain_ip.go @@ -24,9 +24,9 @@ func NewGetCallBackIpResult(result GetCallBackIpResponse, body []byte, http gore // CgiBinGetApiDomainIp 获取微信服务器IP地址 // https://developers.weixin.qq.com/doc/offiaccount/Basic_Information/Get_the_WeChat_server_IP_address.html -func (app *App) CgiBinGetApiDomainIp(componentAccessToken string) *GetCallBackIpResult { +func (c *Client) CgiBinGetApiDomainIp(componentAccessToken string) *GetCallBackIpResult { // 请求 - request, err := app.request(fmt.Sprintf("https://api.weixin.qq.com/cgi-bin/get_api_domain_ip?access_token=%s", componentAccessToken), map[string]interface{}{}, http.MethodGet) + request, err := c.request(fmt.Sprintf("https://api.weixin.qq.com/cgi-bin/get_api_domain_ip?access_token=%s", componentAccessToken), map[string]interface{}{}, http.MethodGet) // 定义 var response GetCallBackIpResponse err = json.Unmarshal(request.ResponseBody, &response) diff --git a/cgi-bin.shorturl.go b/cgi-bin.shorturl.go index 3cbcce4..f0aa3a2 100644 --- a/cgi-bin.shorturl.go +++ b/cgi-bin.shorturl.go @@ -26,13 +26,13 @@ func NewCgiBinShortUrlResult(result CgiBinShortUrlResponse, body []byte, http go // CgiBinShortUrl 将二维码长链接转成短链接 // https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/qrcode/shorturl.html -func (app *App) CgiBinShortUrl(longUrl string) *CgiBinShortUrlResult { +func (c *Client) CgiBinShortUrl(longUrl string) *CgiBinShortUrlResult { // 参数 params := NewParams() params["action"] = "long2short" // 此处填long2short,代表长链接转短链接 params["long_url"] = longUrl // 需要转换的长链接,支持http://、https://、weixin://wxpay 格式的url // 请求 - request, err := app.request(fmt.Sprintf("https://api.weixin.qq.com/cgi-bin/shorturl?access_token=%s", app.GetAuthorizerAccessToken()), params, http.MethodPost) + request, err := c.request(fmt.Sprintf("https://api.weixin.qq.com/cgi-bin/shorturl?access_token=%s", c.GetAuthorizerAccessToken()), params, http.MethodPost) // 定义 var response CgiBinShortUrlResponse err = json.Unmarshal(request.ResponseBody, &response) diff --git a/cgi-bin.wxopen.qrcodejumpadd.go b/cgi-bin.wxopen.qrcodejumpadd.go index 0fbe30c..34facba 100644 --- a/cgi-bin.wxopen.qrcodejumpadd.go +++ b/cgi-bin.wxopen.qrcodejumpadd.go @@ -25,11 +25,11 @@ func NewCgiBinWxOpenQrCodeJumpAddResult(result CgiBinWxOpenQrCodeJumpAddResponse // CgiBinWxOpenQrCodeJumpAdd 增加或修改二维码规则 // https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/qrcode/qrcodejumpadd.html -func (app *App) CgiBinWxOpenQrCodeJumpAdd(notMustParams ...Params) *CgiBinWxOpenQrCodeJumpAddResult { +func (c *Client) CgiBinWxOpenQrCodeJumpAdd(notMustParams ...Params) *CgiBinWxOpenQrCodeJumpAddResult { // 参数 - params := app.NewParamsWith(notMustParams...) + params := c.NewParamsWith(notMustParams...) // 请求 - request, err := app.request(fmt.Sprintf("https://api.weixin.qq.com/cgi-bin/wxopen/qrcodejumpadd?access_token=%s", app.GetAuthorizerAccessToken()), params, http.MethodPost) + request, err := c.request(fmt.Sprintf("https://api.weixin.qq.com/cgi-bin/wxopen/qrcodejumpadd?access_token=%s", c.GetAuthorizerAccessToken()), params, http.MethodPost) // 定义 var response CgiBinWxOpenQrCodeJumpAddResponse err = json.Unmarshal(request.ResponseBody, &response) diff --git a/cgi-bin.wxopen.qrcodejumpdelete.go b/cgi-bin.wxopen.qrcodejumpdelete.go index f68da61..0f42414 100644 --- a/cgi-bin.wxopen.qrcodejumpdelete.go +++ b/cgi-bin.wxopen.qrcodejumpdelete.go @@ -25,12 +25,12 @@ func NewCgiBinWxOpenQrCodeJumpDeleteResult(result CgiBinWxOpenQrCodeJumpDeleteRe // CgiBinWxOpenQrCodeJumpDelete 删除已设置的二维码规则 // https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/qrcode/qrcodejumpdelete.html -func (app *App) CgiBinWxOpenQrCodeJumpDelete(prefix string) *CgiBinWxOpenQrCodeJumpDeleteResult { +func (c *Client) CgiBinWxOpenQrCodeJumpDelete(prefix string) *CgiBinWxOpenQrCodeJumpDeleteResult { // 参数 params := NewParams() params["prefix"] = prefix // 请求 - request, err := app.request(fmt.Sprintf("https://api.weixin.qq.com/cgi-bin/wxopen/qrcodejumpdelete?access_token=%s", app.GetAuthorizerAccessToken()), params, http.MethodPost) + request, err := c.request(fmt.Sprintf("https://api.weixin.qq.com/cgi-bin/wxopen/qrcodejumpdelete?access_token=%s", c.GetAuthorizerAccessToken()), params, http.MethodPost) // 定义 var response CgiBinWxOpenQrCodeJumpDeleteResponse err = json.Unmarshal(request.ResponseBody, &response) diff --git a/cgi-bin.wxopen.qrcodejumpdownloa.go b/cgi-bin.wxopen.qrcodejumpdownloa.go index 57a0f19..0a4a980 100644 --- a/cgi-bin.wxopen.qrcodejumpdownloa.go +++ b/cgi-bin.wxopen.qrcodejumpdownloa.go @@ -27,11 +27,11 @@ func NewCgiBinWxOpenQrCodeJumpDownloadResult(result CgiBinWxOpenQrCodeJumpDownlo // CgiBinWxOpenQrCodeJumpDownload 获取校验文件名称及内容 // https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/qrcode/qrcodejumpdownload.html -func (app *App) CgiBinWxOpenQrCodeJumpDownload() *CgiBinWxOpenQrCodeJumpDownloadResult { +func (c *Client) CgiBinWxOpenQrCodeJumpDownload() *CgiBinWxOpenQrCodeJumpDownloadResult { // 参数 params := NewParams() // 请求 - request, err := app.request(fmt.Sprintf("https://api.weixin.qq.com/cgi-bin/wxopen/qrcodejumpdownload?access_token=%s", app.GetAuthorizerAccessToken()), params, http.MethodPost) + request, err := c.request(fmt.Sprintf("https://api.weixin.qq.com/cgi-bin/wxopen/qrcodejumpdownload?access_token=%s", c.GetAuthorizerAccessToken()), params, http.MethodPost) // 定义 var response CgiBinWxOpenQrCodeJumpDownloadResponse err = json.Unmarshal(request.ResponseBody, &response) diff --git a/cgi-bin.wxopen.qrcodejumpget.go b/cgi-bin.wxopen.qrcodejumpget.go index c4016e0..9a1596c 100644 --- a/cgi-bin.wxopen.qrcodejumpget.go +++ b/cgi-bin.wxopen.qrcodejumpget.go @@ -36,11 +36,11 @@ func NewCgiBinWxOpenQrCodeJumpGetResult(result CgiBinWxOpenQrCodeJumpGetResponse // CgiBinWxOpenQrCodeJumpGet 获取已设置的二维码规则 // https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/qrcode/qrcodejumpadd.html -func (app *App) CgiBinWxOpenQrCodeJumpGet() *CgiBinWxOpenQrCodeJumpGetResult { +func (c *Client) CgiBinWxOpenQrCodeJumpGet() *CgiBinWxOpenQrCodeJumpGetResult { // 参数 params := NewParams() // 请求 - request, err := app.request(fmt.Sprintf("https://api.weixin.qq.com/cgi-bin/wxopen/qrcodejumpget?access_token=%s", app.GetAuthorizerAccessToken()), params, http.MethodPost) + request, err := c.request(fmt.Sprintf("https://api.weixin.qq.com/cgi-bin/wxopen/qrcodejumpget?access_token=%s", c.GetAuthorizerAccessToken()), params, http.MethodPost) // 定义 var response CgiBinWxOpenQrCodeJumpGetResponse err = json.Unmarshal(request.ResponseBody, &response) diff --git a/cgi-bin.wxopen.qrcodejumppublish.go b/cgi-bin.wxopen.qrcodejumppublish.go index 94a90fa..db829dc 100644 --- a/cgi-bin.wxopen.qrcodejumppublish.go +++ b/cgi-bin.wxopen.qrcodejumppublish.go @@ -25,12 +25,12 @@ func NewCgiBinWxOpenQrCodeJumpPublishResult(result CgiBinWxOpenQrCodeJumpPublish // CgiBinWxOpenQrCodeJumpPublish 发布已设置的二维码规则 // https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/qrcode/qrcodejumppublish.html -func (app *App) CgiBinWxOpenQrCodeJumpPublish(prefix string) *CgiBinWxOpenQrCodeJumpPublishResult { +func (c *Client) CgiBinWxOpenQrCodeJumpPublish(prefix string) *CgiBinWxOpenQrCodeJumpPublishResult { // 参数 params := NewParams() params["prefix"] = prefix // 请求 - request, err := app.request(fmt.Sprintf("https://api.weixin.qq.com/cgi-bin/wxopen/qrcodejumppublish?access_token=%s", app.GetAuthorizerAccessToken()), params, http.MethodPost) + request, err := c.request(fmt.Sprintf("https://api.weixin.qq.com/cgi-bin/wxopen/qrcodejumppublish?access_token=%s", c.GetAuthorizerAccessToken()), params, http.MethodPost) // 定义 var response CgiBinWxOpenQrCodeJumpPublishResponse err = json.Unmarshal(request.ResponseBody, &response) diff --git a/get.go b/get.go index 9ed4886..46a23cc 100644 --- a/get.go +++ b/get.go @@ -1,5 +1,5 @@ package wechatopen -func (app *App) GetComponentAppId() string { - return app.componentAppId +func (c *Client) GetComponentAppId() string { + return c.config.ComponentAppId } diff --git a/pgsql.go b/log.go similarity index 93% rename from pgsql.go rename to log.go index 7942cd7..4cacc3a 100644 --- a/pgsql.go +++ b/log.go @@ -8,8 +8,8 @@ import ( ) // 记录日志 -func (app *App) postgresqlLog(request gorequest.Response) { - app.log.Record(golog.ApiPostgresqlLog{ +func (c *Client) postgresqlLog(request gorequest.Response) { + c.log.Record(golog.ApiPostgresqlLog{ RequestTime: golog.TimeString{Time: request.RequestTime}, //【请求】时间 RequestUri: request.RequestUri, //【请求】链接 RequestUrl: gorequest.UriParse(request.RequestUri).Url, //【请求】链接 diff --git a/params.go b/params.go index b404f31..9dc7127 100644 --- a/params.go +++ b/params.go @@ -8,7 +8,7 @@ func NewParams() Params { return p } -func (app *App) NewParamsWith(params ...Params) Params { +func (c *Client) NewParamsWith(params ...Params) Params { p := make(Params) for _, v := range params { p.SetParams(v) diff --git a/redis.go b/redis.go index 543d860..00bae90 100644 --- a/redis.go +++ b/redis.go @@ -7,135 +7,135 @@ import ( ) // 微信后台推送的ticke -func (app *App) getComponentVerifyTicketCacheKeyName() string { - return fmt.Sprintf("wechat_open:component_verify_ticket:%v", app.componentAppId) +func (c *Client) getComponentVerifyTicketCacheKeyName() string { + return fmt.Sprintf("wechat_open:component_verify_ticket:%v", c.config.ComponentAppId) } // SetComponentVerifyTicket 设置微信后台推送的ticke -func (app *App) SetComponentVerifyTicket(componentVerifyTicket string) string { +func (c *Client) SetComponentVerifyTicket(componentVerifyTicket string) string { if componentVerifyTicket == "" { return "" } - app.redis.Db.Set(context.Background(), app.getComponentVerifyTicketCacheKeyName(), componentVerifyTicket, time.Hour*12) - return app.GetComponentVerifyTicket() + c.config.RedisClient.Db.Set(context.Background(), c.getComponentVerifyTicketCacheKeyName(), componentVerifyTicket, time.Hour*12) + return c.GetComponentVerifyTicket() } // GetComponentVerifyTicket 获取微信后台推送的ticke -func (app *App) GetComponentVerifyTicket() string { - if app.redis.Db == nil { - return app.componentVerifyTicket +func (c *Client) GetComponentVerifyTicket() string { + if c.config.RedisClient.Db == nil { + return c.config.ComponentVerifyTicket } - result, _ := app.redis.Db.Get(context.Background(), app.getComponentVerifyTicketCacheKeyName()).Result() + result, _ := c.config.RedisClient.Db.Get(context.Background(), c.getComponentVerifyTicketCacheKeyName()).Result() return result } // 令牌 -func (app *App) getComponentAccessTokenCacheKeyName() string { - return fmt.Sprintf("wechat_open:component_access_token:%v", app.componentAppId) +func (c *Client) getComponentAccessTokenCacheKeyName() string { + return fmt.Sprintf("wechat_open:component_access_token:%v", c.config.ComponentAppId) } // SetComponentAccessToken 设置令牌 -func (app *App) SetComponentAccessToken(componentAccessToken string) string { +func (c *Client) SetComponentAccessToken(componentAccessToken string) string { if componentAccessToken == "" { return "" } - app.redis.Db.Set(context.Background(), app.getComponentAccessTokenCacheKeyName(), componentAccessToken, time.Second*7200) - return app.GetComponentAccessToken() + c.config.RedisClient.Db.Set(context.Background(), c.getComponentAccessTokenCacheKeyName(), componentAccessToken, time.Second*7200) + return c.GetComponentAccessToken() } // GetComponentAccessToken 获取令牌 -func (app *App) GetComponentAccessToken() string { - if app.redis.Db == nil { - return app.componentAccessToken +func (c *Client) GetComponentAccessToken() string { + if c.config.RedisClient.Db == nil { + return c.config.ComponentAccessToken } - result, _ := app.redis.Db.Get(context.Background(), app.getComponentAccessTokenCacheKeyName()).Result() + result, _ := c.config.RedisClient.Db.Get(context.Background(), c.getComponentAccessTokenCacheKeyName()).Result() return result } // MonitorComponentAccessToken 监控令牌 -func (app *App) MonitorComponentAccessToken() string { +func (c *Client) MonitorComponentAccessToken() string { // 查询 - componentAccessToken := app.GetComponentAccessToken() + componentAccessToken := c.GetComponentAccessToken() // 判断 - result := app.CgiBinGetApiDomainIp(componentAccessToken) + result := c.CgiBinGetApiDomainIp(componentAccessToken) if len(result.Result.IpList) > 0 { return componentAccessToken } // 重新获取 - return app.SetComponentAccessToken(app.CgiBinComponentApiComponentToken().Result.ComponentAccessToken) + return c.SetComponentAccessToken(c.CgiBinComponentApiComponentToken().Result.ComponentAccessToken) } // 授权方令牌 -func (app *App) getAuthorizerAccessTokenCacheKeyName() string { - return fmt.Sprintf("wechat_open:authorizer_access_token:%v:%v", app.componentAppId, app.authorizerAppid) +func (c *Client) getAuthorizerAccessTokenCacheKeyName() string { + return fmt.Sprintf("wechat_open:authorizer_access_token:%v:%v", c.config.ComponentAppId, c.config.AuthorizerAppid) } // SetAuthorizerAccessToken 设置授权方令牌 -func (app *App) SetAuthorizerAccessToken(authorizerAccessToken string) string { +func (c *Client) SetAuthorizerAccessToken(authorizerAccessToken string) string { if authorizerAccessToken == "" { return "" } - app.redis.Db.Set(context.Background(), app.getAuthorizerAccessTokenCacheKeyName(), authorizerAccessToken, time.Hour*2) - return app.GetComponentAccessToken() + c.config.RedisClient.Db.Set(context.Background(), c.getAuthorizerAccessTokenCacheKeyName(), authorizerAccessToken, time.Hour*2) + return c.GetComponentAccessToken() } // GetAuthorizerAccessToken 获取授权方令牌 -func (app *App) GetAuthorizerAccessToken() string { - if app.redis.Db == nil { - return app.authorizerAccessToken +func (c *Client) GetAuthorizerAccessToken() string { + if c.config.RedisClient.Db == nil { + return c.config.AuthorizerAccessToken } - result, _ := app.redis.Db.Get(context.Background(), app.getAuthorizerAccessTokenCacheKeyName()).Result() + result, _ := c.config.RedisClient.Db.Get(context.Background(), c.getAuthorizerAccessTokenCacheKeyName()).Result() return result } // MonitorAuthorizerAccessToken 监控授权方令牌 -func (app *App) MonitorAuthorizerAccessToken(authorizerRefreshToken string) string { +func (c *Client) MonitorAuthorizerAccessToken(authorizerRefreshToken string) string { // 查询 - authorizerAccessToken := app.GetAuthorizerAccessToken() + authorizerAccessToken := c.GetAuthorizerAccessToken() // 判断 if authorizerAccessToken != "" { return authorizerAccessToken } // 重新获取 - return app.SetAuthorizerAccessToken(app.CgiBinComponentApiAuthorizerToken(authorizerRefreshToken).Result.AuthorizerAccessToken) + return c.SetAuthorizerAccessToken(c.CgiBinComponentApiAuthorizerToken(authorizerRefreshToken).Result.AuthorizerAccessToken) } // 预授权码 -func (app *App) getPreAuthCodeCacheKeyName() string { - return fmt.Sprintf("wechat_open:pre_auth_code:%v", app.componentAppId) +func (c *Client) getPreAuthCodeCacheKeyName() string { + return fmt.Sprintf("wechat_open:pre_auth_code:%v", c.config.ComponentAppId) } // SetPreAuthCode 设置预授权码 -func (app *App) SetPreAuthCode(preAuthCode string) string { +func (c *Client) SetPreAuthCode(preAuthCode string) string { if preAuthCode == "" { return "" } - app.redis.Db.Set(context.Background(), app.getPreAuthCodeCacheKeyName(), preAuthCode, time.Second*1700) - return app.GetComponentAccessToken() + c.config.RedisClient.Db.Set(context.Background(), c.getPreAuthCodeCacheKeyName(), preAuthCode, time.Second*1700) + return c.GetComponentAccessToken() } // GetPreAuthCode 获取预授权码 -func (app *App) GetPreAuthCode() string { - if app.redis.Db == nil { - return app.authorizerAccessToken +func (c *Client) GetPreAuthCode() string { + if c.config.RedisClient.Db == nil { + return c.config.AuthorizerAccessToken } - result, _ := app.redis.Db.Get(context.Background(), app.getPreAuthCodeCacheKeyName()).Result() + result, _ := c.config.RedisClient.Db.Get(context.Background(), c.getPreAuthCodeCacheKeyName()).Result() return result } // DelPreAuthCode 删除预授权码 -func (app *App) DelPreAuthCode() error { - return app.redis.Db.Del(context.Background(), app.getPreAuthCodeCacheKeyName()).Err() +func (c *Client) DelPreAuthCode() error { + return c.config.RedisClient.Db.Del(context.Background(), c.getPreAuthCodeCacheKeyName()).Err() } // MonitorPreAuthCode 监控预授权码 -func (app *App) MonitorPreAuthCode() string { +func (c *Client) MonitorPreAuthCode() string { // 查询 - preAuthCode := app.GetPreAuthCode() + preAuthCode := c.GetPreAuthCode() // 判断 if preAuthCode != "" { return preAuthCode } // 重新获取 - return app.SetPreAuthCode(app.CgiBinComponentApiCreatePreAuthCoden().Result.PreAuthCode) + return c.SetPreAuthCode(c.CgiBinComponentApiCreatePreAuthCoden().Result.PreAuthCode) } diff --git a/save_img.go b/save_img.go index bcf8147..3871417 100644 --- a/save_img.go +++ b/save_img.go @@ -11,7 +11,7 @@ type SaveImgResponse struct { Name string } -func (app *App) SaveImg(resp gorequest.Response, dir, saveName string) SaveImgResponse { +func (c *Client) SaveImg(resp gorequest.Response, dir, saveName string) SaveImgResponse { // 返回是二进制图片,或者json错误 if resp.ResponseHeader.Get("Content-Type") == "image/jpeg" || resp.ResponseHeader.Get("Content-Type") == "image/png" { // 保存在output目录 diff --git a/service_http.authorizer_appid.go b/service_http.authorizer_appid.go index 8249000..c95e829 100644 --- a/service_http.authorizer_appid.go +++ b/service_http.authorizer_appid.go @@ -7,7 +7,7 @@ import ( ) // ServeHttpAuthorizerAppid 授权跳转 -func (app *App) ServeHttpAuthorizerAppid(r *http.Request) (resp CgiBinComponentApiQueryAuthResponse, agentUserId string, err error) { +func (c *Client) ServeHttpAuthorizerAppid(r *http.Request) (resp CgiBinComponentApiQueryAuthResponse, agentUserId string, err error) { var ( query = r.URL.Query() @@ -25,7 +25,7 @@ func (app *App) ServeHttpAuthorizerAppid(r *http.Request) (resp CgiBinComponentA return resp, agentUserId, errors.New("找不到过期时间参数") } - info := app.CgiBinComponentApiQueryAuth(authCode) + info := c.CgiBinComponentApiQueryAuth(authCode) if info.Result.AuthorizationInfo.AuthorizerAppid == "" { return resp, agentUserId, errors.New("获取失败") } diff --git a/service_http.verify_ticket.go b/service_http.verify_ticket.go index b965ac2..69aafc9 100644 --- a/service_http.verify_ticket.go +++ b/service_http.verify_ticket.go @@ -26,7 +26,7 @@ type cipherRequestHttpBody struct { } // ServeHttpVerifyTicket 验证票据推送 -func (app *App) ServeHttpVerifyTicket(r *http.Request) (resp *ResponseServeHttpVerifyTicket, err error) { +func (c *Client) ServeHttpVerifyTicket(r *http.Request) (resp *ResponseServeHttpVerifyTicket, err error) { var ( query = r.URL.Query() @@ -57,7 +57,7 @@ func (app *App) ServeHttpVerifyTicket(r *http.Request) (resp *ResponseServeHttpV return resp, errors.New("未找到随机数参数") } - wantSignature = Sign(app.messageToken, timestamp, nonce) + wantSignature = Sign(c.config.MessageToken, timestamp, nonce) if haveSignature != wantSignature { return resp, errors.New("签名错误") } @@ -96,7 +96,7 @@ func (app *App) ServeHttpVerifyTicket(r *http.Request) (resp *ResponseServeHttpV return resp, errors.New(fmt.Sprintf("Encrypt 解码字符串错误:%v", err)) } - AesKey, err := base64.StdEncoding.DecodeString(app.messageKey + "=") + AesKey, err := base64.StdEncoding.DecodeString(c.config.MessageKey + "=") if err != nil { return resp, errors.New(fmt.Sprintf("messageKey 解码字符串错误:%v", err)) } diff --git a/set.go b/set.go index b539289..50a98cd 100644 --- a/set.go +++ b/set.go @@ -1,7 +1,7 @@ package wechatopen // SetAuthorizerAppid 设置代理商小程序 -func (app *App) SetAuthorizerAppid(authorizerAppid string) { - app.authorizerAppid = authorizerAppid +func (c *Client) SetAuthorizerAppid(authorizerAppid string) { + c.config.AuthorizerAppid = authorizerAppid return } diff --git a/sns.component.jscode2session.go b/sns.component.jscode2session.go index d3378ab..e0d0e2a 100644 --- a/sns.component.jscode2session.go +++ b/sns.component.jscode2session.go @@ -30,16 +30,16 @@ func NewSnsComponentJsCode2sessionResult(result SnsComponentJsCode2sessionRespon // SnsComponentJsCode2session 小程序登录 // https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/others/WeChat_login.html -func (app *App) SnsComponentJsCode2session(jsCode string) *SnsComponentJsCode2sessionResult { +func (c *Client) SnsComponentJsCode2session(jsCode string) *SnsComponentJsCode2sessionResult { // 参数 params := NewParams() - params["appid"] = app.authorizerAppid // 小程序的 appId - params["js_code"] = jsCode // wx.login 获取的 code - params["grant_type"] = "authorization_code" // 填 authorization_code - params["component_appid"] = app.componentAppId // 第三方平台 appid - params["component_access_token"] = app.GetComponentAccessToken() // 第三方平台的component_access_token + params["appid"] = c.config.AuthorizerAppid // 小程序的 appId + params["js_code"] = jsCode // wx.login 获取的 code + params["grant_type"] = "authorization_code" // 填 authorization_code + params["component_appid"] = c.config.ComponentAppId // 第三方平台 appid + params["component_access_token"] = c.GetComponentAccessToken() // 第三方平台的component_access_token // 请求 - request, err := app.request("https://api.weixin.qq.com/sns/component/jscode2session", params, http.MethodGet) + request, err := c.request("https://api.weixin.qq.com/sns/component/jscode2session", params, http.MethodGet) // 定义 var response SnsComponentJsCode2sessionResponse err = json.Unmarshal(request.ResponseBody, &response) diff --git a/version.go b/version.go index fdb5497..cbd2844 100644 --- a/version.go +++ b/version.go @@ -1,3 +1,3 @@ package wechatopen -const Version = "1.0.2" +const Version = "1.0.3" diff --git a/wechatopen.go b/wechatopen.go index 4f15d4a..99d5186 100644 --- a/wechatopen.go +++ b/wechatopen.go @@ -7,59 +7,64 @@ import ( "gorm.io/gorm" ) -// App 微信公众号服务 -type App struct { - componentAccessToken string // 第三方平台 access_token - componentVerifyTicket string // 微信后台推送的 ticket - preAuthCode string // 预授权码 - authorizerAccessToken string // 接口调用令牌 - authorizerRefreshToken string // 刷新令牌 - authorizerAppid string // 授权方 appid - componentAppId string // 第三方平台 appid - componentAppSecret string // 第三方平台 app_secret - messageToken string - messageKey string - redis *dorm.RedisClient // 缓存数据库 - pgsql *gorm.DB // pgsql数据库 - client *gorequest.App // 请求客户端 - log *golog.Api // 日志服务 - logTableName string // 日志表名 - logStatus bool // 日志状态 +type ConfigClient struct { + ComponentAccessToken string // 第三方平台 access_token + ComponentVerifyTicket string // 微信后台推送的 ticket + PreAuthCode string // 预授权码 + AuthorizerAccessToken string // 接口调用令牌 + AuthorizerRefreshToken string // 刷新令牌 + AuthorizerAppid string // 授权方 appid + ComponentAppId string // 第三方平台 appid + ComponentAppSecret string // 第三方平台 app_secret + MessageToken string + MessageKey string + RedisClient *dorm.RedisClient // 缓存数据库 + PgsqlDb *gorm.DB // pgsql数据库 } -// NewApp 实例化 -func NewApp(componentAppId string, componentAppSecret string, messageToken string, messageKey string, redis *dorm.RedisClient, pgsql *gorm.DB) *App { - app := &App{componentAppId: componentAppId, componentAppSecret: componentAppSecret, messageToken: messageToken, messageKey: messageKey, redis: redis} - app.client = gorequest.NewHttp() - if pgsql != nil { - app.pgsql = pgsql - app.logStatus = true - app.logTableName = "wechatopen" - app.log = golog.NewApi(&golog.ApiConfig{ - Db: pgsql, - TableName: app.logTableName, +// Client 微信公众号服务 +type Client struct { + client *gorequest.App // 请求客户端 + log *golog.Api // 日志服务 + logTableName string // 日志表名 + logStatus bool // 日志状态 + config *ConfigClient // 配置 +} + +func NewClient(config *ConfigClient) *Client { + + c := &Client{config: config} + + c.client = gorequest.NewHttp() + if c.config.PgsqlDb != nil { + c.logStatus = true + c.logTableName = "wechatopen" + c.log = golog.NewApi(&golog.ApiConfig{ + Db: c.config.PgsqlDb, + TableName: c.logTableName, }) } - return app + + return c } -// Config 配置 -func (app *App) Config(componentAppId, componentAppSecret string) *App { - app.componentAppId = componentAppId - app.componentAppSecret = componentAppSecret - return app +// ConfigComponent 配置 +func (c *Client) ConfigComponent(componentAppId, componentAppSecret string) *Client { + c.config.ComponentAppId = componentAppId + c.config.ComponentAppSecret = componentAppSecret + return c } // ConfigAuthorizer 配置第三方 -func (app *App) ConfigAuthorizer(authorizerAppid string) *App { - app.authorizerAppid = authorizerAppid - return app +func (c *Client) ConfigAuthorizer(authorizerAppid string) *Client { + c.config.AuthorizerAppid = authorizerAppid + return c } -func (app *App) request(url string, params map[string]interface{}, method string) (resp gorequest.Response, err error) { +func (c *Client) request(url string, params map[string]interface{}, method string) (resp gorequest.Response, err error) { // 创建请求 - client := app.client + client := c.client // 设置请求地址 client.SetUri(url) @@ -80,8 +85,8 @@ func (app *App) request(url string, params map[string]interface{}, method string } // 日志 - if app.logStatus == true { - go app.postgresqlLog(request) + if c.logStatus == true { + go c.postgresqlLog(request) } return request, err diff --git a/wxa.addtotemplate.go b/wxa.addtotemplate.go index d1abf0f..6deb37d 100644 --- a/wxa.addtotemplate.go +++ b/wxa.addtotemplate.go @@ -25,13 +25,13 @@ func NewWxaAddToTemplateResult(result WxaAddToTemplateResponse, body []byte, htt // WxaAddToTemplate 将草稿添加到代码模板库 // https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/ThirdParty/code_template/addtotemplate.html -func (app *App) WxaAddToTemplate(draftId string, templateType int) *WxaAddToTemplateResult { +func (c *Client) WxaAddToTemplate(draftId string, templateType int) *WxaAddToTemplateResult { // 参数 params := NewParams() params["draft_id"] = draftId params["template_type"] = templateType // 请求 - request, err := app.request(fmt.Sprintf("https://api.weixin.qq.com/wxa/addtotemplate?access_token=%s", app.GetComponentAccessToken()), params, http.MethodPost) + request, err := c.request(fmt.Sprintf("https://api.weixin.qq.com/wxa/addtotemplate?access_token=%s", c.GetComponentAccessToken()), params, http.MethodPost) // 定义 var response WxaAddToTemplateResponse err = json.Unmarshal(request.ResponseBody, &response) diff --git a/wxa.bind_tester.go b/wxa.bind_tester.go index ec8ff03..25d4ec5 100644 --- a/wxa.bind_tester.go +++ b/wxa.bind_tester.go @@ -26,12 +26,12 @@ func NewWxaBindTesterResult(result WxaBindTesterResponse, body []byte, http gore // WxaBindTester 绑定微信用户为体验者 // https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/Mini_Program_AdminManagement/Admin.html -func (app *App) WxaBindTester(wechatid string) *WxaBindTesterResult { +func (c *Client) WxaBindTester(wechatid string) *WxaBindTesterResult { // 参数 params := NewParams() params["wechatid"] = wechatid // 请求 - request, err := app.request(fmt.Sprintf("https://api.weixin.qq.com/wxa/bind_tester?access_token=%s", app.GetAuthorizerAccessToken()), params, http.MethodPost) + request, err := c.request(fmt.Sprintf("https://api.weixin.qq.com/wxa/bind_tester?access_token=%s", c.GetAuthorizerAccessToken()), params, http.MethodPost) // 定义 var response WxaBindTesterResponse err = json.Unmarshal(request.ResponseBody, &response) diff --git a/wxa.business.getuserphonenumber.go b/wxa.business.getuserphonenumber.go index 4dcbc54..c2fa74c 100644 --- a/wxa.business.getuserphonenumber.go +++ b/wxa.business.getuserphonenumber.go @@ -34,12 +34,12 @@ func NewWxaBusinessGetUserPhoneNumberResult(result WxaBusinessGetUserPhoneNumber // WxaBusinessGetUserPhoneNumber code换取用户手机号。 每个 code 只能使用一次,code的有效期为5min // https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/phonenumber/phonenumber.getPhoneNumber.html -func (app *App) WxaBusinessGetUserPhoneNumber(code string) *WxaBusinessGetUserPhoneNumberResult { +func (c *Client) WxaBusinessGetUserPhoneNumber(code string) *WxaBusinessGetUserPhoneNumberResult { // 参数 params := gorequest.NewParams() params.Set("code", code) // 请求 - request, err := app.request(fmt.Sprintf("https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token=%s", app.GetAuthorizerAccessToken()), params, http.MethodPost) + request, err := c.request(fmt.Sprintf("https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token=%s", c.GetAuthorizerAccessToken()), params, http.MethodPost) // 定义 var response WxaBusinessGetUserPhoneNumberResponse err = json.Unmarshal(request.ResponseBody, &response) diff --git a/wxa.commit.go b/wxa.commit.go index ac567da..b34c9b4 100644 --- a/wxa.commit.go +++ b/wxa.commit.go @@ -25,11 +25,11 @@ func NewWxaCommitResult(result WxaCommitResponse, body []byte, http gorequest.Re // WxaCommit 上传小程序代码并生成体验版 // https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/code/commit.html -func (app *App) WxaCommit(notMustParams ...gorequest.Params) *WxaCommitResult { +func (c *Client) WxaCommit(notMustParams ...gorequest.Params) *WxaCommitResult { // 参数 params := gorequest.NewParamsWith(notMustParams...) // 请求 - request, err := app.request(fmt.Sprintf("https://api.weixin.qq.com/wxa/commit?access_token=%s", app.GetAuthorizerAccessToken()), params, http.MethodPost) + request, err := c.request(fmt.Sprintf("https://api.weixin.qq.com/wxa/commit?access_token=%s", c.GetAuthorizerAccessToken()), params, http.MethodPost) // 定义 var response WxaCommitResponse err = json.Unmarshal(request.ResponseBody, &response) diff --git a/wxa.deletetemplate.go b/wxa.deletetemplate.go index 88e3987..593760c 100644 --- a/wxa.deletetemplate.go +++ b/wxa.deletetemplate.go @@ -25,12 +25,12 @@ func NewWxaDeleteTemplateResult(result WxaDeleteTemplateResponse, body []byte, h // WxaDeleteTemplate 删除指定代码模板 // https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/ThirdParty/code_template/deletetemplate.html -func (app *App) WxaDeleteTemplate(templateId string) *WxaDeleteTemplateResult { +func (c *Client) WxaDeleteTemplate(templateId string) *WxaDeleteTemplateResult { // 参数 params := NewParams() params.Set("template_id", templateId) // 请求 - request, err := app.request(fmt.Sprintf("https://api.weixin.qq.com/wxa/deletetemplate?access_token=%s", app.GetComponentAccessToken()), params, http.MethodPost) + request, err := c.request(fmt.Sprintf("https://api.weixin.qq.com/wxa/deletetemplate?access_token=%s", c.GetComponentAccessToken()), params, http.MethodPost) // 定义 var response WxaDeleteTemplateResponse err = json.Unmarshal(request.ResponseBody, &response) diff --git a/wxa.get_auditstatus.go b/wxa.get_auditstatus.go index 13a97f7..d586e94 100644 --- a/wxa.get_auditstatus.go +++ b/wxa.get_auditstatus.go @@ -29,12 +29,12 @@ func NewWxaGetAuditStatusResult(result WxaGetAuditStatusResponse, body []byte, h // WxaGetAuditStatus 查询指定发布审核单的审核状态 // https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/code/get_auditstatus.html -func (app *App) WxaGetAuditStatus(auditid int64) *WxaGetAuditStatusResult { +func (c *Client) WxaGetAuditStatus(auditid int64) *WxaGetAuditStatusResult { // 参数 - params := app.NewParamsWith() + params := c.NewParamsWith() params.Set("auditid", auditid) // 请求 - request, err := app.request(fmt.Sprintf("https://api.weixin.qq.com/wxa/get_auditstatus?access_token=%s", app.GetAuthorizerAccessToken()), params, http.MethodPost) + request, err := c.request(fmt.Sprintf("https://api.weixin.qq.com/wxa/get_auditstatus?access_token=%s", c.GetAuthorizerAccessToken()), params, http.MethodPost) // 定义 var response WxaGetAuditStatusResponse err = json.Unmarshal(request.ResponseBody, &response) diff --git a/wxa.get_category.go b/wxa.get_category.go index 6e43bb0..9881c2f 100644 --- a/wxa.get_category.go +++ b/wxa.get_category.go @@ -33,9 +33,9 @@ func NewWxaGetCategoryResult(result WxaGetCategoryResponse, body []byte, http go // WxaGetCategory 获取审核时可填写的类目信息 // https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/category/get_category.html -func (app *App) WxaGetCategory() *WxaGetCategoryResult { +func (c *Client) WxaGetCategory() *WxaGetCategoryResult { // 请求 - request, err := app.request(fmt.Sprintf("https://api.weixin.qq.com/wxa/get_category?access_token=%s", app.GetAuthorizerAccessToken()), map[string]interface{}{}, http.MethodGet) + request, err := c.request(fmt.Sprintf("https://api.weixin.qq.com/wxa/get_category?access_token=%s", c.GetAuthorizerAccessToken()), map[string]interface{}{}, http.MethodGet) // 定义 var response WxaGetCategoryResponse err = json.Unmarshal(request.ResponseBody, &response) diff --git a/wxa.get_effective_domain.go b/wxa.get_effective_domain.go index 12eb0df..5d74390 100644 --- a/wxa.get_effective_domain.go +++ b/wxa.get_effective_domain.go @@ -49,11 +49,11 @@ func NewWxaGetEffectiveDomainResult(result WxaGetEffectiveDomainResponse, body [ // WxaGetEffectiveDomain 获取发布后生效服务器域名列表 // https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/Mini_Program_Basic_Info/get_effective_domain.html -func (app *App) WxaGetEffectiveDomain(notMustParams ...Params) *WxaGetEffectiveDomainResult { +func (c *Client) WxaGetEffectiveDomain(notMustParams ...Params) *WxaGetEffectiveDomainResult { // 参数 - params := app.NewParamsWith(notMustParams...) + params := c.NewParamsWith(notMustParams...) // 请求 - request, err := app.request(fmt.Sprintf("https://api.weixin.qq.com/wxa/get_effective_domain?access_token=%s", app.GetAuthorizerAccessToken()), params, http.MethodPost) + request, err := c.request(fmt.Sprintf("https://api.weixin.qq.com/wxa/get_effective_domain?access_token=%s", c.GetAuthorizerAccessToken()), params, http.MethodPost) // 定义 var response WxaGetEffectiveDomainResponse err = json.Unmarshal(request.ResponseBody, &response) diff --git a/wxa.get_latest_auditstatus.go b/wxa.get_latest_auditstatus.go index 620b680..252b6cd 100644 --- a/wxa.get_latest_auditstatus.go +++ b/wxa.get_latest_auditstatus.go @@ -29,9 +29,9 @@ func NewWxaGetLatestAuditStatusResult(result WxaGetLatestAuditStatusResponse, bo // WxaGetLatestAuditStatus 查询最新一次提交的审核状态 // https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/code/get_auditstatus.html -func (app *App) WxaGetLatestAuditStatus() *WxaGetLatestAuditStatusResult { +func (c *Client) WxaGetLatestAuditStatus() *WxaGetLatestAuditStatusResult { // 请求 - request, err := app.request(fmt.Sprintf("https://api.weixin.qq.com/wxa/get_latest_auditstatus?access_token=%s", app.GetAuthorizerAccessToken()), map[string]interface{}{}, http.MethodPost) + request, err := c.request(fmt.Sprintf("https://api.weixin.qq.com/wxa/get_latest_auditstatus?access_token=%s", c.GetAuthorizerAccessToken()), map[string]interface{}{}, http.MethodPost) // 定义 var response WxaGetLatestAuditStatusResponse err = json.Unmarshal(request.ResponseBody, &response) diff --git a/wxa.get_page.go b/wxa.get_page.go index 5353c41..7d86569 100644 --- a/wxa.get_page.go +++ b/wxa.get_page.go @@ -26,9 +26,9 @@ func NewWxaGetPageResult(result WxaGetPageResponse, body []byte, http gorequest. // WxaGetPage 获取已上传的代码的页面列表 // https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/code/get_page.html -func (app *App) WxaGetPage() *WxaGetPageResult { +func (c *Client) WxaGetPage() *WxaGetPageResult { // 请求 - request, err := app.request(fmt.Sprintf("https://api.weixin.qq.com/wxa/get_page?access_token=%s", app.GetAuthorizerAccessToken()), map[string]interface{}{}, http.MethodGet) + request, err := c.request(fmt.Sprintf("https://api.weixin.qq.com/wxa/get_page?access_token=%s", c.GetAuthorizerAccessToken()), map[string]interface{}{}, http.MethodGet) // 定义 var response WxaGetPageResponse err = json.Unmarshal(request.ResponseBody, &response) diff --git a/wxa.get_qrcode.go b/wxa.get_qrcode.go index 6e0c542..92b431e 100644 --- a/wxa.get_qrcode.go +++ b/wxa.get_qrcode.go @@ -25,14 +25,14 @@ func NewWxaGetQrcodeResult(result WxaGetQrcodeResponse, body []byte, http gorequ // WxaGetQrcode 获取体验版二维码 // https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/code/get_qrcode.html -func (app *App) WxaGetQrcode(path string) *WxaGetQrcodeResult { +func (c *Client) WxaGetQrcode(path string) *WxaGetQrcodeResult { // 参数 params := NewParams() if path != "" { params["path"] = path // 指定二维码扫码后直接进入指定页面并可同时带上参数) } // 请求 - request, err := app.request(fmt.Sprintf("https://api.weixin.qq.com/wxa/get_qrcode?access_token=%s", app.GetAuthorizerAccessToken()), params, http.MethodGet) + request, err := c.request(fmt.Sprintf("https://api.weixin.qq.com/wxa/get_qrcode?access_token=%s", c.GetAuthorizerAccessToken()), params, http.MethodGet) // 定义 var response WxaGetQrcodeResponse err = json.Unmarshal(request.ResponseBody, &response) diff --git a/wxa.gettemplatedraftlist.go b/wxa.gettemplatedraftlist.go index a6e66ae..3cb085c 100644 --- a/wxa.gettemplatedraftlist.go +++ b/wxa.gettemplatedraftlist.go @@ -35,9 +35,9 @@ func NewWxaGetTemplateDraftListResult(result WxaGetTemplateDraftListResponse, bo // WxaGetTemplateDraftList 获取代码草稿列表 // https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/ThirdParty/code_template/gettemplatedraftlist.html -func (app *App) WxaGetTemplateDraftList() *WxaGetTemplateDraftListResult { +func (c *Client) WxaGetTemplateDraftList() *WxaGetTemplateDraftListResult { // 请求 - request, err := app.request(fmt.Sprintf("https://api.weixin.qq.com/wxa/gettemplatedraftlist?access_token=%s", app.GetComponentAccessToken()), map[string]interface{}{}, http.MethodGet) + request, err := c.request(fmt.Sprintf("https://api.weixin.qq.com/wxa/gettemplatedraftlist?access_token=%s", c.GetComponentAccessToken()), map[string]interface{}{}, http.MethodGet) // 定义 var response WxaGetTemplateDraftListResponse err = json.Unmarshal(request.ResponseBody, &response) diff --git a/wxa.gettemplatelist.go b/wxa.gettemplatelist.go index 26978e4..e00a482 100644 --- a/wxa.gettemplatelist.go +++ b/wxa.gettemplatelist.go @@ -36,9 +36,9 @@ func NewWxaGetTemplateListResult(result WxaGetTemplateListResponse, body []byte, // WxaGetTemplateList 获取代码模板列表 // https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/ThirdParty/code_template/gettemplatelist.html -func (app *App) WxaGetTemplateList() *WxaGetTemplateListResult { +func (c *Client) WxaGetTemplateList() *WxaGetTemplateListResult { // 请求 - request, err := app.request(fmt.Sprintf("https://api.weixin.qq.com/wxa/gettemplatelist?access_token=%s", app.GetComponentAccessToken()), map[string]interface{}{}, http.MethodGet) + request, err := c.request(fmt.Sprintf("https://api.weixin.qq.com/wxa/gettemplatelist?access_token=%s", c.GetComponentAccessToken()), map[string]interface{}{}, http.MethodGet) // 定义 var response WxaGetTemplateListResponse err = json.Unmarshal(request.ResponseBody, &response) diff --git a/wxa.getversioninfo.go b/wxa.getversioninfo.go index dfbdefb..8c2cb41 100644 --- a/wxa.getversioninfo.go +++ b/wxa.getversioninfo.go @@ -36,13 +36,13 @@ func NewWxaGetVersionInfoResult(result WxaGetVersionInfoResponse, body []byte, h // WxaGetVersionInfo 查询小程序版本信息 // https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/code/get_versioninfo.html -func (app *App) WxaGetVersionInfo() *WxaGetVersionInfoResult { - accessToken := app.GetAuthorizerAccessToken() +func (c *Client) WxaGetVersionInfo() *WxaGetVersionInfoResult { + accessToken := c.GetAuthorizerAccessToken() if accessToken == "" { return NewWxaGetVersionInfoResult(WxaGetVersionInfoResponse{}, nil, gorequest.Response{}, errors.New("访问令牌为空")) } // 请求 - request, err := app.request(fmt.Sprintf("https://api.weixin.qq.com/wxa/getversioninfo?access_token=%s", accessToken), map[string]interface{}{}, http.MethodPost) + request, err := c.request(fmt.Sprintf("https://api.weixin.qq.com/wxa/getversioninfo?access_token=%s", accessToken), map[string]interface{}{}, http.MethodPost) // 定义 var response WxaGetVersionInfoResponse err = json.Unmarshal(request.ResponseBody, &response) diff --git a/wxa.getwxacodeunlimit.go b/wxa.getwxacodeunlimit.go index 69bc26d..b224bb6 100644 --- a/wxa.getwxacodeunlimit.go +++ b/wxa.getwxacodeunlimit.go @@ -27,11 +27,11 @@ func NewWxaGetWxaCodeUnLimitResult(result WxaGetWxaCodeUnLimitResponse, body []b // WxaGetWxaCodeUnLimit 获取小程序码,适用于需要的码数量极多的业务场景。通过该接口生成的小程序码,永久有效,数量暂无限制 // https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/qr-code/wxacode.getUnlimited.html -func (app *App) WxaGetWxaCodeUnLimit(notMustParams ...Params) *WxaGetWxaCodeUnLimitResult { +func (c *Client) WxaGetWxaCodeUnLimit(notMustParams ...Params) *WxaGetWxaCodeUnLimitResult { // 参数 - params := app.NewParamsWith(notMustParams...) + params := c.NewParamsWith(notMustParams...) // 请求 - request, err := app.request(fmt.Sprintf("https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=%s", app.GetAuthorizerAccessToken()), params, http.MethodPost) + request, err := c.request(fmt.Sprintf("https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=%s", c.GetAuthorizerAccessToken()), params, http.MethodPost) // 定义 var response WxaGetWxaCodeUnLimitResponse err = json.Unmarshal(request.ResponseBody, &response) diff --git a/wxa.memberauth.go b/wxa.memberauth.go index 9718b9b..f86805a 100644 --- a/wxa.memberauth.go +++ b/wxa.memberauth.go @@ -29,8 +29,8 @@ func NewWxaMemberAuthResult(result WxaMemberAuthResponse, body []byte, http gore // WxaMemberAuth 获取体验者列表 // https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/Mini_Program_AdminManagement/memberauth.html -func (app *App) WxaMemberAuth() *WxaMemberAuthResult { - accessToken := app.GetAuthorizerAccessToken() +func (c *Client) WxaMemberAuth() *WxaMemberAuthResult { + accessToken := c.GetAuthorizerAccessToken() if accessToken == "" { return NewWxaMemberAuthResult(WxaMemberAuthResponse{}, nil, gorequest.Response{}, errors.New("访问令牌为空")) } @@ -38,7 +38,7 @@ func (app *App) WxaMemberAuth() *WxaMemberAuthResult { params := NewParams() params["action"] = "get_experiencer" // 请求 - request, err := app.request(fmt.Sprintf("https://api.weixin.qq.com/wxa/memberauth?access_token=%s", accessToken), params, http.MethodPost) + request, err := c.request(fmt.Sprintf("https://api.weixin.qq.com/wxa/memberauth?access_token=%s", accessToken), params, http.MethodPost) // 定义 var response WxaMemberAuthResponse err = json.Unmarshal(request.ResponseBody, &response) diff --git a/wxa.modify_domain.go b/wxa.modify_domain.go index a4e8241..2b58a38 100644 --- a/wxa.modify_domain.go +++ b/wxa.modify_domain.go @@ -38,11 +38,11 @@ func NewWxaModifyDomainResult(result WxaModifyDomainResponse, body []byte, http // WxaModifyDomain 设置服务器域名 // https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/Mini_Program_Basic_Info/Server_Address_Configuration.html -func (app *App) WxaModifyDomain(notMustParams ...Params) *WxaModifyDomainResult { +func (c *Client) WxaModifyDomain(notMustParams ...Params) *WxaModifyDomainResult { // 参数 - params := app.NewParamsWith(notMustParams...) + params := c.NewParamsWith(notMustParams...) // 请求 - request, err := app.request(fmt.Sprintf("https://api.weixin.qq.com/wxa/modify_domain?access_token=%s", app.GetAuthorizerAccessToken()), params, http.MethodPost) + request, err := c.request(fmt.Sprintf("https://api.weixin.qq.com/wxa/modify_domain?access_token=%s", c.GetAuthorizerAccessToken()), params, http.MethodPost) // 定义 var response WxaModifyDomainResponse err = json.Unmarshal(request.ResponseBody, &response) diff --git a/wxa.modify_domain_directly.go b/wxa.modify_domain_directly.go index 6a3021d..4eb0b24 100644 --- a/wxa.modify_domain_directly.go +++ b/wxa.modify_domain_directly.go @@ -25,11 +25,11 @@ func NewWxaModifyDomainDirectlyResult(result WxaModifyDomainDirectlyResponse, bo // WxaModifyDomainDirectly 快速设置小程序服务器域名 // https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/Mini_Program_Basic_Info/modify_domain_directly.html -func (app *App) WxaModifyDomainDirectly(notMustParams ...Params) *WxaModifyDomainDirectlyResult { +func (c *Client) WxaModifyDomainDirectly(notMustParams ...Params) *WxaModifyDomainDirectlyResult { // 参数 - params := app.NewParamsWith(notMustParams...) + params := c.NewParamsWith(notMustParams...) // 请求 - request, err := app.request(fmt.Sprintf("https://api.weixin.qq.com/wxa/modify_domain_directly?access_token=%s", app.GetAuthorizerAccessToken()), params, http.MethodPost) + request, err := c.request(fmt.Sprintf("https://api.weixin.qq.com/wxa/modify_domain_directly?access_token=%s", c.GetAuthorizerAccessToken()), params, http.MethodPost) // 定义 var response WxaModifyDomainDirectlyResponse err = json.Unmarshal(request.ResponseBody, &response) diff --git a/wxa.release.go b/wxa.release.go index d502ee3..327ef9e 100644 --- a/wxa.release.go +++ b/wxa.release.go @@ -25,11 +25,11 @@ func NewWxaReleaseResult(result WxaReleaseResponse, body []byte, http gorequest. // WxaRelease 发布已通过审核的小程序 // https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/code/release.html -func (app *App) WxaRelease() *WxaReleaseResult { +func (c *Client) WxaRelease() *WxaReleaseResult { // 参数 params := NewParams() // 请求 - request, err := app.request(fmt.Sprintf("https://api.weixin.qq.com/wxa/release?access_token=%s", app.GetAuthorizerAccessToken()), params, http.MethodPost) + request, err := c.request(fmt.Sprintf("https://api.weixin.qq.com/wxa/release?access_token=%s", c.GetAuthorizerAccessToken()), params, http.MethodPost) // 定义 var response WxaReleaseResponse err = json.Unmarshal(request.ResponseBody, &response) diff --git a/wxa.security.apply_privacy_interface.go b/wxa.security.apply_privacy_interface.go index ee848db..5b3b150 100644 --- a/wxa.security.apply_privacy_interface.go +++ b/wxa.security.apply_privacy_interface.go @@ -26,11 +26,11 @@ func NewWxaSecurityApplyPrivacyInterfaceResult(result WxaSecurityApplyPrivacyInt // WxaSecurityApplyPrivacyInterface 申请接口 // https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/apply_api/apply_privacy_interface.html -func (app *App) WxaSecurityApplyPrivacyInterface(notMustParams ...Params) *WxaSecurityApplyPrivacyInterfaceResult { +func (c *Client) WxaSecurityApplyPrivacyInterface(notMustParams ...Params) *WxaSecurityApplyPrivacyInterfaceResult { // 参数 - params := app.NewParamsWith(notMustParams...) + params := c.NewParamsWith(notMustParams...) // 请求 - request, err := app.request(fmt.Sprintf("https://api.weixin.qq.com/wxa/security/apply_privacy_interface?access_token=%s", app.GetAuthorizerAccessToken()), params, http.MethodPost) + request, err := c.request(fmt.Sprintf("https://api.weixin.qq.com/wxa/security/apply_privacy_interface?access_token=%s", c.GetAuthorizerAccessToken()), params, http.MethodPost) // 定义 var response WxaSecurityApplyPrivacyInterfaceResponse err = json.Unmarshal(request.ResponseBody, &response) diff --git a/wxa.security.get_privacy_interface.go b/wxa.security.get_privacy_interface.go index ed7ab0f..f9225bb 100644 --- a/wxa.security.get_privacy_interface.go +++ b/wxa.security.get_privacy_interface.go @@ -36,11 +36,11 @@ func NewWxaSecurityGetPrivacyInterfaceResult(result WxaSecurityGetPrivacyInterfa // WxaSecurityGetPrivacyInterface 获取接口列表 // https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/apply_api/get_privacy_interface.html -func (app *App) WxaSecurityGetPrivacyInterface() *WxaSecurityGetPrivacyInterfaceResult { +func (c *Client) WxaSecurityGetPrivacyInterface() *WxaSecurityGetPrivacyInterfaceResult { // 参数 params := NewParams() // 请求 - request, err := app.request(fmt.Sprintf("https://api.weixin.qq.com/wxa/security/get_privacy_interface?access_token=%s", app.GetAuthorizerAccessToken()), params, http.MethodGet) + request, err := c.request(fmt.Sprintf("https://api.weixin.qq.com/wxa/security/get_privacy_interface?access_token=%s", c.GetAuthorizerAccessToken()), params, http.MethodGet) // 定义 var response WxaSecurityGetPrivacyInterfaceResponse err = json.Unmarshal(request.ResponseBody, &response) diff --git a/wxa.submit_audit.go b/wxa.submit_audit.go index e5b09d8..aa5f783 100644 --- a/wxa.submit_audit.go +++ b/wxa.submit_audit.go @@ -26,11 +26,11 @@ func NewWxaSubmitAuditResult(result WxaSubmitAuditResponse, body []byte, http go // WxaSubmitAudit 提交审核 // https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/code/submit_audit.html -func (app *App) WxaSubmitAudit(notMustParams ...Params) *WxaSubmitAuditResult { +func (c *Client) WxaSubmitAudit(notMustParams ...Params) *WxaSubmitAuditResult { // 参数 - params := app.NewParamsWith(notMustParams...) + params := c.NewParamsWith(notMustParams...) // 请求 - request, err := app.request(fmt.Sprintf("https://api.weixin.qq.com/wxa/submit_audit?access_token=%s", app.GetAuthorizerAccessToken()), params, http.MethodPost) + request, err := c.request(fmt.Sprintf("https://api.weixin.qq.com/wxa/submit_audit?access_token=%s", c.GetAuthorizerAccessToken()), params, http.MethodPost) // 定义 var response WxaSubmitAuditResponse err = json.Unmarshal(request.ResponseBody, &response) diff --git a/wxa.unbind_tester.go b/wxa.unbind_tester.go index 97d90d9..edba973 100644 --- a/wxa.unbind_tester.go +++ b/wxa.unbind_tester.go @@ -25,7 +25,7 @@ func NewWxaUnbindTesterResult(result WxaUnbindTesterResponse, body []byte, http // WxaUnbindTester 解除绑定体验者 // https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/Mini_Program_AdminManagement/unbind_tester.html -func (app *App) WxaUnbindTester(wechatid, userstr string) *WxaUnbindTesterResult { +func (c *Client) WxaUnbindTester(wechatid, userstr string) *WxaUnbindTesterResult { // 参数 params := NewParams() if wechatid != "" { @@ -33,7 +33,7 @@ func (app *App) WxaUnbindTester(wechatid, userstr string) *WxaUnbindTesterResult } params["userstr"] = userstr // 请求 - request, err := app.request(fmt.Sprintf("https://api.weixin.qq.com/wxa/unbind_tester?access_token=%s", app.GetAuthorizerAccessToken()), params, http.MethodPost) + request, err := c.request(fmt.Sprintf("https://api.weixin.qq.com/wxa/unbind_tester?access_token=%s", c.GetAuthorizerAccessToken()), params, http.MethodPost) // 定义 var response WxaUnbindTesterResponse err = json.Unmarshal(request.ResponseBody, &response)