From 2bffadd1162510aa805bdcfa1cee6fd878daee7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=85=89=E6=98=A5?= Date: Fri, 12 Aug 2022 22:51:34 +0800 Subject: [PATCH] - update request --- cgi-bin.account.getaccountbasicinfo.go | 2 +- cgi-bin.component.api_authorizer_token.go | 2 +- cgi-bin.component.api_component_token.go | 6 +- cgi-bin.component.api_create_preauthcode.go | 2 +- cgi-bin.component.api_get_authorizer_info.go | 2 +- cgi-bin.component.api_query_auth.go | 2 +- cgi-bin.component.getprivacysetting.go | 2 +- cgi-bin.component.setprivacysetting.go | 2 +- cgi-bin.shorturl.go | 2 +- cgi-bin.wxopen.qrcodejumpadd.go | 2 +- cgi-bin.wxopen.qrcodejumpdelete.go | 2 +- cgi-bin.wxopen.qrcodejumpdownloa.go | 2 +- cgi-bin.wxopen.qrcodejumpget.go | 2 +- cgi-bin.wxopen.qrcodejumppublish.go | 2 +- const.go | 2 +- go.mod | 2 +- go.sum | 17 +----- redis.go | 64 ++++++++++---------- save_img.go | 3 +- sns.component.jscode2session.go | 10 +-- tcb.wxpaylist.go | 2 +- wxa.addtotemplate.go | 2 +- wxa.bind_tester.go | 2 +- wxa.business.getuserphonenumber.go | 2 +- wxa.commit.go | 2 +- wxa.deletetemplate.go | 2 +- wxa.get_auditstatus.go | 2 +- wxa.get_category.go | 2 +- wxa.get_effective_domain.go | 2 +- wxa.get_latest_auditstatus.go | 2 +- wxa.get_page.go | 2 +- wxa.get_qrcode.go | 2 +- wxa.gettemplatedraftlist.go | 2 +- wxa.gettemplatelist.go | 2 +- wxa.getversioninfo.go | 2 +- wxa.getwxacodeunlimit.go | 2 +- wxa.memberauth.go | 2 +- wxa.modify_domain.go | 2 +- wxa.modify_domain_directly.go | 2 +- wxa.release.go | 2 +- wxa.security.apply_privacy_interface.go | 2 +- wxa.security.get_privacy_interface.go | 2 +- wxa.submit_audit.go | 2 +- wxa.unbind_tester.go | 2 +- 44 files changed, 83 insertions(+), 95 deletions(-) diff --git a/cgi-bin.account.getaccountbasicinfo.go b/cgi-bin.account.getaccountbasicinfo.go index f1b3aef..8ebdef7 100644 --- a/cgi-bin.account.getaccountbasicinfo.go +++ b/cgi-bin.account.getaccountbasicinfo.go @@ -58,7 +58,7 @@ func newCgiBinAccountGetAccountBasicInfoResult(result CgiBinAccountGetAccountBas // https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/Mini_Program_Basic_Info/Mini_Program_Information_Settings.html func (c *Client) CgiBinAccountGetAccountBasicInfo(ctx context.Context) *CgiBinAccountGetAccountBasicInfoResult { // 请求 - request, err := c.request(ctx, fmt.Sprintf(apiUrl+"/cgi-bin/account/getaccountbasicinfo?access_token=%v", c.GetAuthorizerAccessToken()), map[string]interface{}{}, http.MethodGet) + request, err := c.request(ctx, fmt.Sprintf(apiUrl+"/cgi-bin/account/getaccountbasicinfo?access_token=%v", c.GetAuthorizerAccessToken(ctx)), 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 06ff916..d318bed 100644 --- a/cgi-bin.component.api_authorizer_token.go +++ b/cgi-bin.component.api_authorizer_token.go @@ -36,7 +36,7 @@ func (c *Client) CgiBinComponentApiAuthorizerToken(ctx context.Context, authoriz param["authorizer_refresh_token"] = authorizerRefreshToken // 授权码, 会在授权成功时返回给第三方平台 params := gorequest.NewParamsWith(param) // 请求 - request, err := c.request(ctx, fmt.Sprintf(apiUrl+"/cgi-bin/component/api_authorizer_token?component_access_token=%v", c.GetComponentAccessToken()), params, http.MethodPost) + request, err := c.request(ctx, fmt.Sprintf(apiUrl+"/cgi-bin/component/api_authorizer_token?component_access_token=%v", c.GetComponentAccessToken(ctx)), params, http.MethodPost) // 定义 var response CgiBinComponentApiAuthorizerTokenResponse err = json.Unmarshal(request.ResponseBody, &response) diff --git a/cgi-bin.component.api_component_token.go b/cgi-bin.component.api_component_token.go index 3509030..53412ed 100644 --- a/cgi-bin.component.api_component_token.go +++ b/cgi-bin.component.api_component_token.go @@ -28,9 +28,9 @@ func newCgiBinComponentApiComponentTokenResult(result CgiBinComponentApiComponen func (c *Client) CgiBinComponentApiComponentToken(ctx context.Context) *CgiBinComponentApiComponentTokenResult { // 参数 param := gorequest.NewParams() - param["component_appid"] = c.config.ComponentAppId // 第三方平台 appid - param["component_appsecret"] = c.config.ComponentAppSecret // 第三方平台 appsecret - param["component_verify_ticket"] = c.GetComponentVerifyTicket() // 微信后台推送的 ticket + param["component_appid"] = c.config.ComponentAppId // 第三方平台 appid + param["component_appsecret"] = c.config.ComponentAppSecret // 第三方平台 appsecret + param["component_verify_ticket"] = c.GetComponentVerifyTicket(ctx) // 微信后台推送的 ticket params := gorequest.NewParamsWith(param) // 请求 request, err := c.request(ctx, apiUrl+"/cgi-bin/component/api_component_token", params, http.MethodPost) diff --git a/cgi-bin.component.api_create_preauthcode.go b/cgi-bin.component.api_create_preauthcode.go index c4d42ba..357e345 100644 --- a/cgi-bin.component.api_create_preauthcode.go +++ b/cgi-bin.component.api_create_preauthcode.go @@ -32,7 +32,7 @@ func (c *Client) CgiBinComponentApiCreatePreAuthCoden(ctx context.Context) *CgiB param["component_appid"] = c.config.ComponentAppId // 第三方平台 appid params := gorequest.NewParamsWith(param) // 请求 - request, err := c.request(ctx, fmt.Sprintf(apiUrl+"/cgi-bin/component/api_create_preauthcode?component_access_token=%v", c.GetComponentAccessToken()), params, http.MethodPost) + request, err := c.request(ctx, fmt.Sprintf(apiUrl+"/cgi-bin/component/api_create_preauthcode?component_access_token=%v", c.GetComponentAccessToken(ctx)), 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 aa5fd66..812216e 100644 --- a/cgi-bin.component.api_get_authorizer_info.go +++ b/cgi-bin.component.api_get_authorizer_info.go @@ -91,7 +91,7 @@ func (c *Client) CgiBinComponentApiGetAuthorizerInfo(ctx context.Context) *CgiBi param["authorizer_appid"] = c.config.AuthorizerAppid // 授权方 appid params := gorequest.NewParamsWith(param) // 请求 - request, err := c.request(ctx, fmt.Sprintf(apiUrl+"/cgi-bin/component/api_get_authorizer_info?component_access_token=%v", c.GetComponentAccessToken()), params, http.MethodPost) + request, err := c.request(ctx, fmt.Sprintf(apiUrl+"/cgi-bin/component/api_get_authorizer_info?component_access_token=%v", c.GetComponentAccessToken(ctx)), 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 aee649a..aeb63fd 100644 --- a/cgi-bin.component.api_query_auth.go +++ b/cgi-bin.component.api_query_auth.go @@ -47,7 +47,7 @@ func (c *Client) CgiBinComponentApiQueryAuth(ctx context.Context, authorizationC param["authorization_code"] = authorizationCode // 授权码, 会在授权成功时返回给第三方平台 params := gorequest.NewParamsWith(param) // 请求 - request, err := c.request(ctx, fmt.Sprintf(apiUrl+"/cgi-bin/component/api_query_auth?component_access_token=%v", c.GetComponentAccessToken()), params, http.MethodPost) + request, err := c.request(ctx, fmt.Sprintf(apiUrl+"/cgi-bin/component/api_query_auth?component_access_token=%v", c.GetComponentAccessToken(ctx)), params, http.MethodPost) // 定义 var response CgiBinComponentApiQueryAuthResponse err = json.Unmarshal(request.ResponseBody, &response) diff --git a/cgi-bin.component.getprivacysetting.go b/cgi-bin.component.getprivacysetting.go index 5dd5551..7fe6ebc 100644 --- a/cgi-bin.component.getprivacysetting.go +++ b/cgi-bin.component.getprivacysetting.go @@ -64,7 +64,7 @@ func (c *Client) CgiBinComponentGetPrivacySetting(ctx context.Context, privacyVe params := gorequest.NewParams() params["privacy_ver"] = privacyVer // 请求 - request, err := c.request(ctx, fmt.Sprintf(apiUrl+"/cgi-bin/component/getprivacysetting?access_token=%s", c.GetAuthorizerAccessToken()), params, http.MethodPost) + request, err := c.request(ctx, fmt.Sprintf(apiUrl+"/cgi-bin/component/getprivacysetting?access_token=%s", c.GetAuthorizerAccessToken(ctx)), 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 05ab664..aa12d36 100644 --- a/cgi-bin.component.setprivacysetting.go +++ b/cgi-bin.component.setprivacysetting.go @@ -30,7 +30,7 @@ func (c *Client) CgiBinComponentSetPrivacySetting(ctx context.Context, notMustPa // 参数 params := gorequest.NewParamsWith(notMustParams...) // 请求 - request, err := c.request(ctx, fmt.Sprintf(apiUrl+"/cgi-bin/component/setprivacysetting?access_token=%s", c.GetAuthorizerAccessToken()), params, http.MethodPost) + request, err := c.request(ctx, fmt.Sprintf(apiUrl+"/cgi-bin/component/setprivacysetting?access_token=%s", c.GetAuthorizerAccessToken(ctx)), params, http.MethodPost) // 定义 var response CgiBinComponentSetPrivacySettingResponse err = json.Unmarshal(request.ResponseBody, &response) diff --git a/cgi-bin.shorturl.go b/cgi-bin.shorturl.go index b9c49f6..05a8194 100644 --- a/cgi-bin.shorturl.go +++ b/cgi-bin.shorturl.go @@ -33,7 +33,7 @@ func (c *Client) CgiBinShortUrl(ctx context.Context, longUrl string) *CgiBinShor params["action"] = "long2short" // 此处填long2short,代表长链接转短链接 params["long_url"] = longUrl // 需要转换的长链接,支持http://、https://、weixin://wxpay 格式的url // 请求 - request, err := c.request(ctx, fmt.Sprintf(apiUrl+"/cgi-bin/shorturl?access_token=%s", c.GetAuthorizerAccessToken()), params, http.MethodPost) + request, err := c.request(ctx, fmt.Sprintf(apiUrl+"/cgi-bin/shorturl?access_token=%s", c.GetAuthorizerAccessToken(ctx)), 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 8122973..ce51156 100644 --- a/cgi-bin.wxopen.qrcodejumpadd.go +++ b/cgi-bin.wxopen.qrcodejumpadd.go @@ -30,7 +30,7 @@ func (c *Client) CgiBinWxOpenQrCodeJumpAdd(ctx context.Context, notMustParams .. // 参数 params := gorequest.NewParamsWith(notMustParams...) // 请求 - request, err := c.request(ctx, fmt.Sprintf(apiUrl+"/cgi-bin/wxopen/qrcodejumpadd?access_token=%s", c.GetAuthorizerAccessToken()), params, http.MethodPost) + request, err := c.request(ctx, fmt.Sprintf(apiUrl+"/cgi-bin/wxopen/qrcodejumpadd?access_token=%s", c.GetAuthorizerAccessToken(ctx)), 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 55b76f6..c87ea5d 100644 --- a/cgi-bin.wxopen.qrcodejumpdelete.go +++ b/cgi-bin.wxopen.qrcodejumpdelete.go @@ -31,7 +31,7 @@ func (c *Client) CgiBinWxOpenQrCodeJumpDelete(ctx context.Context, prefix string params := gorequest.NewParams() params["prefix"] = prefix // 请求 - request, err := c.request(ctx, fmt.Sprintf(apiUrl+"/cgi-bin/wxopen/qrcodejumpdelete?access_token=%s", c.GetAuthorizerAccessToken()), params, http.MethodPost) + request, err := c.request(ctx, fmt.Sprintf(apiUrl+"/cgi-bin/wxopen/qrcodejumpdelete?access_token=%s", c.GetAuthorizerAccessToken(ctx)), 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 582ecd1..7e1d9eb 100644 --- a/cgi-bin.wxopen.qrcodejumpdownloa.go +++ b/cgi-bin.wxopen.qrcodejumpdownloa.go @@ -32,7 +32,7 @@ func (c *Client) CgiBinWxOpenQrCodeJumpDownload(ctx context.Context) *CgiBinWxOp // 参数 params := gorequest.NewParams() // 请求 - request, err := c.request(ctx, fmt.Sprintf(apiUrl+"/cgi-bin/wxopen/qrcodejumpdownload?access_token=%s", c.GetAuthorizerAccessToken()), params, http.MethodPost) + request, err := c.request(ctx, fmt.Sprintf(apiUrl+"/cgi-bin/wxopen/qrcodejumpdownload?access_token=%s", c.GetAuthorizerAccessToken(ctx)), 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 06b4f62..36e0604 100644 --- a/cgi-bin.wxopen.qrcodejumpget.go +++ b/cgi-bin.wxopen.qrcodejumpget.go @@ -41,7 +41,7 @@ func (c *Client) CgiBinWxOpenQrCodeJumpGet(ctx context.Context) *CgiBinWxOpenQrC // 参数 params := gorequest.NewParams() // 请求 - request, err := c.request(ctx, fmt.Sprintf(apiUrl+"/cgi-bin/wxopen/qrcodejumpget?access_token=%s", c.GetAuthorizerAccessToken()), params, http.MethodPost) + request, err := c.request(ctx, fmt.Sprintf(apiUrl+"/cgi-bin/wxopen/qrcodejumpget?access_token=%s", c.GetAuthorizerAccessToken(ctx)), 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 a8d7126..992cddb 100644 --- a/cgi-bin.wxopen.qrcodejumppublish.go +++ b/cgi-bin.wxopen.qrcodejumppublish.go @@ -31,7 +31,7 @@ func (c *Client) CgiBinWxOpenQrCodeJumpPublish(ctx context.Context, prefix strin params := gorequest.NewParams() params["prefix"] = prefix // 请求 - request, err := c.request(ctx, fmt.Sprintf(apiUrl+"/cgi-bin/wxopen/qrcodejumppublish?access_token=%s", c.GetAuthorizerAccessToken()), params, http.MethodPost) + request, err := c.request(ctx, fmt.Sprintf(apiUrl+"/cgi-bin/wxopen/qrcodejumppublish?access_token=%s", c.GetAuthorizerAccessToken(ctx)), params, http.MethodPost) // 定义 var response CgiBinWxOpenQrCodeJumpPublishResponse err = json.Unmarshal(request.ResponseBody, &response) diff --git a/const.go b/const.go index 0662686..3fb6d05 100644 --- a/const.go +++ b/const.go @@ -8,4 +8,4 @@ const ( logTable = "wechatopen" ) -const Version = "1.0.7" +const Version = "1.0.8" diff --git a/go.mod b/go.mod index 67ebb20..2ba1a77 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.19 require ( github.com/mitchellh/mapstructure v1.5.0 - go.dtapp.net/dorm v1.0.16 + go.dtapp.net/dorm v1.0.17 go.dtapp.net/golog v1.0.22 go.dtapp.net/gorequest v1.0.24 gorm.io/gorm v1.23.8 diff --git a/go.sum b/go.sum index 3670cc0..e6ceecd 100644 --- a/go.sum +++ b/go.sum @@ -185,7 +185,6 @@ github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANyt github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo= github.com/ipfs/go-detect-race v0.0.1 h1:qX/xay2W3E4Q1U7d9lNs1sU9nvguX0a7319XbyQ6cOk= github.com/ipfs/go-detect-race v0.0.1/go.mod h1:8BNT7shDZPo99Q74BpGMK+4D8Mn4j46UU0LZ723meps= -github.com/jackc/chunkreader v1.0.0 h1:4s39bBR8ByfqH+DKm8rQA3E1LHZWB9XWcrz8fqaZbe0= github.com/jackc/chunkreader v1.0.0/go.mod h1:RT6O25fNZIuasFJRyZ4R/Y2BbhasbmZXF9QQ7T3kePo= github.com/jackc/chunkreader/v2 v2.0.0/go.mod h1:odVSm741yZoC3dpHEUXIqA9tQRhFrgOHwnPIn9lDKlk= github.com/jackc/chunkreader/v2 v2.0.1 h1:i+RDz65UE+mmpjTfyz0MoVTnzeYxroil2G82ki7MGG8= @@ -212,7 +211,6 @@ github.com/jackc/pgmock v0.0.0-20210724152146-4ad1a8207f65 h1:DadwsjnMwFjfWc9y5W github.com/jackc/pgmock v0.0.0-20210724152146-4ad1a8207f65/go.mod h1:5R2h2EEX+qri8jOWMbJCtaPWkrrNc7OHwsp2TCqp7ak= github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM= github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg= -github.com/jackc/pgproto3 v1.1.0 h1:FYYE4yRw+AgI8wXIinMlNjBbp/UitDJwfj5LqqewP1A= github.com/jackc/pgproto3 v1.1.0/go.mod h1:eR5FA3leWg7p9aeAqi37XOTgTIbkABlvcPB3E5rlc78= github.com/jackc/pgproto3/v2 v2.0.0-alpha1.0.20190420180111-c116219b62db/go.mod h1:bhq50y+xrl9n5mRYyCBFKkpRVTLYJVWeCc+mEAI3yXA= github.com/jackc/pgproto3/v2 v2.0.0-alpha1.0.20190609003834-432c2951c711/go.mod h1:uH0AWtUmuShn0bcesswc4aBTWGvw0cAxIJp+6OB//Wg= @@ -470,7 +468,6 @@ github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhV github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tmthrgd/go-hex v0.0.0-20190904060850-447a3041c3bc h1:9lRDQMhESg+zvGYmW5DyG0UqvY96Bu5QYsTLvCHdrgo= github.com/tmthrgd/go-hex v0.0.0-20190904060850-447a3041c3bc/go.mod h1:bciPuU6GHm1iF1pBvUfxfsH0Wmnc2VbpgvbI9ZWuIRs= -github.com/ugorji/go v1.2.7 h1:qYhyWUUd6WbiM+C6JZAUkIJt/1WrjzNHY9+KCIjVqTo= github.com/ugorji/go v1.2.7/go.mod h1:nF9osbDWLy6bDVv/Rtoh6QgnvNDpmCalQV5urGCCS6M= github.com/ugorji/go/codec v1.2.7 h1:YPXUKf7fYbp/y8xloBqZOw2qaVggbfwMlI8WM3wZUJ0= github.com/ugorji/go/codec v1.2.7/go.mod h1:WGN1fab3R1fzQlVQTkfxVtIBhWDRqOviHU95kRgeqEY= @@ -505,16 +502,12 @@ github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a/go.mod h1:ul22v+Nro/ github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/zenazn/goji v0.9.0/go.mod h1:7S9M489iMyHBNxwZnk9/EHS098H4/F6TATF2mIxtB1Q= github.com/ziutek/mymysql v1.5.4/go.mod h1:LMSpPZ6DbqWFxNCHW77HeMg9I646SAhApZ/wKdgO/C0= -go.dtapp.net/dorm v1.0.14 h1:HDsaMwKGlKFKt59Y3hPI9aVnSjfXOyjoHw2uoXErKEo= -go.dtapp.net/dorm v1.0.14/go.mod h1:bHG7BmgeLaAlc56myYF63lwZAIuMeWRAqHBb/L84dLM= -go.dtapp.net/dorm v1.0.16 h1:aLBW9mgXjN9enV7cAqNpErQPDZk1oM6JxX62vz6hTdQ= -go.dtapp.net/dorm v1.0.16/go.mod h1:bHG7BmgeLaAlc56myYF63lwZAIuMeWRAqHBb/L84dLM= +go.dtapp.net/dorm v1.0.17 h1:3VQKUl05CDxFg3T1c/M8wYf2I+H+oVGBDh4NCV30nn0= +go.dtapp.net/dorm v1.0.17/go.mod h1:bHG7BmgeLaAlc56myYF63lwZAIuMeWRAqHBb/L84dLM= go.dtapp.net/goip v1.0.24 h1:62k3xt9I/YLUwA5tLp7YC8XPskkswc4RJrvxRRxjwIY= go.dtapp.net/goip v1.0.24/go.mod h1:tps0yoq5kSykLGDb01vuai47hzAQ6nYUPFWLdlQA2Oo= go.dtapp.net/gojson v1.0.1 h1:MHeSGlq1KxzL7rCkm18fhwW4GNORHohdDMmxY5PupKY= go.dtapp.net/gojson v1.0.1/go.mod h1:TkkpTNxHBKxul0e7gC5MrL1K4ICFB9mQ7wHzjBah3/k= -go.dtapp.net/golog v1.0.21 h1:pSGmDz3SJTH7M/NvVLZb+YJd8uNl5g18aORibuaY2JU= -go.dtapp.net/golog v1.0.21/go.mod h1:Wxm2Kh77JN5zFDZ72el9E9c/YkoJnOvHVusB7SqvoC8= go.dtapp.net/golog v1.0.22 h1:sOJr5f/iLk/6irT/RuwTQSTwvL2DR8SIhzMsKdHo0Ic= go.dtapp.net/golog v1.0.22/go.mod h1:sbn2WQXmlukcZ4T3Kz9iWOSznL8H3RCkD+1nicZHMfI= go.dtapp.net/gorandom v1.0.1 h1:IWfMClh1ECPvyUjlqD7MwLq4mZdUusD1qAwAdsvEJBs= @@ -539,8 +532,6 @@ go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= -go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE= -go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ= go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= go.uber.org/goleak v1.1.11 h1:wy28qYRKZgnJTxGxvye5/wgWr1EKjmUDGYox5mGlRlI= @@ -613,8 +604,6 @@ golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwY golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210610132358-84b48f89b13b/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20220809184613-07c6da5e1ced h1:3dYNDff0VT5xj+mbj2XucFst9WKk6PdGOrb9n+SbIvw= -golang.org/x/net v0.0.0-20220809184613-07c6da5e1ced/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= golang.org/x/net v0.0.0-20220811182439-13a9a731de15 h1:cik0bxZUSJVDyaHf1hZPSDsU8SZHGQZQMeueXCE7yBQ= golang.org/x/net v0.0.0-20220811182439-13a9a731de15/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -661,8 +650,6 @@ golang.org/x/sys v0.0.0-20210902050250-f475640dd07b/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211210111614-af8b64212486/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220808155132-1c4a2a72c664 h1:v1W7bwXHsnLLloWYTVEdvGvA7BHMeBYsPcF0GLDxIRs= -golang.org/x/sys v0.0.0-20220808155132-1c4a2a72c664/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab h1:2QkjZIsXupsJbJIdSjjUOgWK3aEtzyuh2mPt3l/CkeU= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= diff --git a/redis.go b/redis.go index 00bae90..f5050d1 100644 --- a/redis.go +++ b/redis.go @@ -12,20 +12,20 @@ func (c *Client) getComponentVerifyTicketCacheKeyName() string { } // SetComponentVerifyTicket 设置微信后台推送的ticke -func (c *Client) SetComponentVerifyTicket(componentVerifyTicket string) string { +func (c *Client) SetComponentVerifyTicket(ctx context.Context, componentVerifyTicket string) string { if componentVerifyTicket == "" { return "" } - c.config.RedisClient.Db.Set(context.Background(), c.getComponentVerifyTicketCacheKeyName(), componentVerifyTicket, time.Hour*12) - return c.GetComponentVerifyTicket() + c.config.RedisClient.Set(ctx, c.getComponentVerifyTicketCacheKeyName(), componentVerifyTicket, time.Hour*12) + return c.GetComponentVerifyTicket(ctx) } // GetComponentVerifyTicket 获取微信后台推送的ticke -func (c *Client) GetComponentVerifyTicket() string { +func (c *Client) GetComponentVerifyTicket(ctx context.Context) string { if c.config.RedisClient.Db == nil { return c.config.ComponentVerifyTicket } - result, _ := c.config.RedisClient.Db.Get(context.Background(), c.getComponentVerifyTicketCacheKeyName()).Result() + result, _ := c.config.RedisClient.Get(ctx, c.getComponentVerifyTicketCacheKeyName()).Result() return result } @@ -35,34 +35,34 @@ func (c *Client) getComponentAccessTokenCacheKeyName() string { } // SetComponentAccessToken 设置令牌 -func (c *Client) SetComponentAccessToken(componentAccessToken string) string { +func (c *Client) SetComponentAccessToken(ctx context.Context, componentAccessToken string) string { if componentAccessToken == "" { return "" } - c.config.RedisClient.Db.Set(context.Background(), c.getComponentAccessTokenCacheKeyName(), componentAccessToken, time.Second*7200) - return c.GetComponentAccessToken() + c.config.RedisClient.Set(ctx, c.getComponentAccessTokenCacheKeyName(), componentAccessToken, time.Second*7200) + return c.GetComponentAccessToken(ctx) } // GetComponentAccessToken 获取令牌 -func (c *Client) GetComponentAccessToken() string { +func (c *Client) GetComponentAccessToken(ctx context.Context) string { if c.config.RedisClient.Db == nil { return c.config.ComponentAccessToken } - result, _ := c.config.RedisClient.Db.Get(context.Background(), c.getComponentAccessTokenCacheKeyName()).Result() + result, _ := c.config.RedisClient.Db.Get(ctx, c.getComponentAccessTokenCacheKeyName()).Result() return result } // MonitorComponentAccessToken 监控令牌 -func (c *Client) MonitorComponentAccessToken() string { +func (c *Client) MonitorComponentAccessToken(ctx context.Context) string { // 查询 - componentAccessToken := c.GetComponentAccessToken() + componentAccessToken := c.GetComponentAccessToken(ctx) // 判断 - result := c.CgiBinGetApiDomainIp(componentAccessToken) + result := c.CgiBinGetApiDomainIp(ctx, componentAccessToken) if len(result.Result.IpList) > 0 { return componentAccessToken } // 重新获取 - return c.SetComponentAccessToken(c.CgiBinComponentApiComponentToken().Result.ComponentAccessToken) + return c.SetComponentAccessToken(ctx, c.CgiBinComponentApiComponentToken(ctx).Result.ComponentAccessToken) } // 授权方令牌 @@ -71,33 +71,33 @@ func (c *Client) getAuthorizerAccessTokenCacheKeyName() string { } // SetAuthorizerAccessToken 设置授权方令牌 -func (c *Client) SetAuthorizerAccessToken(authorizerAccessToken string) string { +func (c *Client) SetAuthorizerAccessToken(ctx context.Context, authorizerAccessToken string) string { if authorizerAccessToken == "" { return "" } - c.config.RedisClient.Db.Set(context.Background(), c.getAuthorizerAccessTokenCacheKeyName(), authorizerAccessToken, time.Hour*2) - return c.GetComponentAccessToken() + c.config.RedisClient.Set(ctx, c.getAuthorizerAccessTokenCacheKeyName(), authorizerAccessToken, time.Hour*2) + return c.GetComponentAccessToken(ctx) } // GetAuthorizerAccessToken 获取授权方令牌 -func (c *Client) GetAuthorizerAccessToken() string { +func (c *Client) GetAuthorizerAccessToken(ctx context.Context) string { if c.config.RedisClient.Db == nil { return c.config.AuthorizerAccessToken } - result, _ := c.config.RedisClient.Db.Get(context.Background(), c.getAuthorizerAccessTokenCacheKeyName()).Result() + result, _ := c.config.RedisClient.Get(ctx, c.getAuthorizerAccessTokenCacheKeyName()).Result() return result } // MonitorAuthorizerAccessToken 监控授权方令牌 -func (c *Client) MonitorAuthorizerAccessToken(authorizerRefreshToken string) string { +func (c *Client) MonitorAuthorizerAccessToken(ctx context.Context, authorizerRefreshToken string) string { // 查询 - authorizerAccessToken := c.GetAuthorizerAccessToken() + authorizerAccessToken := c.GetAuthorizerAccessToken(ctx) // 判断 if authorizerAccessToken != "" { return authorizerAccessToken } // 重新获取 - return c.SetAuthorizerAccessToken(c.CgiBinComponentApiAuthorizerToken(authorizerRefreshToken).Result.AuthorizerAccessToken) + return c.SetAuthorizerAccessToken(ctx, c.CgiBinComponentApiAuthorizerToken(ctx, authorizerRefreshToken).Result.AuthorizerAccessToken) } // 预授权码 @@ -106,36 +106,36 @@ func (c *Client) getPreAuthCodeCacheKeyName() string { } // SetPreAuthCode 设置预授权码 -func (c *Client) SetPreAuthCode(preAuthCode string) string { +func (c *Client) SetPreAuthCode(ctx context.Context, preAuthCode string) string { if preAuthCode == "" { return "" } - c.config.RedisClient.Db.Set(context.Background(), c.getPreAuthCodeCacheKeyName(), preAuthCode, time.Second*1700) - return c.GetComponentAccessToken() + c.config.RedisClient.Set(ctx, c.getPreAuthCodeCacheKeyName(), preAuthCode, time.Second*1700) + return c.GetComponentAccessToken(ctx) } // GetPreAuthCode 获取预授权码 -func (c *Client) GetPreAuthCode() string { +func (c *Client) GetPreAuthCode(ctx context.Context) string { if c.config.RedisClient.Db == nil { return c.config.AuthorizerAccessToken } - result, _ := c.config.RedisClient.Db.Get(context.Background(), c.getPreAuthCodeCacheKeyName()).Result() + result, _ := c.config.RedisClient.Get(ctx, c.getPreAuthCodeCacheKeyName()).Result() return result } // DelPreAuthCode 删除预授权码 -func (c *Client) DelPreAuthCode() error { - return c.config.RedisClient.Db.Del(context.Background(), c.getPreAuthCodeCacheKeyName()).Err() +func (c *Client) DelPreAuthCode(ctx context.Context) error { + return c.config.RedisClient.Del(ctx, c.getPreAuthCodeCacheKeyName()).Err() } // MonitorPreAuthCode 监控预授权码 -func (c *Client) MonitorPreAuthCode() string { +func (c *Client) MonitorPreAuthCode(ctx context.Context) string { // 查询 - preAuthCode := c.GetPreAuthCode() + preAuthCode := c.GetPreAuthCode(ctx) // 判断 if preAuthCode != "" { return preAuthCode } // 重新获取 - return c.SetPreAuthCode(c.CgiBinComponentApiCreatePreAuthCoden().Result.PreAuthCode) + return c.SetPreAuthCode(ctx, c.CgiBinComponentApiCreatePreAuthCoden(ctx).Result.PreAuthCode) } diff --git a/save_img.go b/save_img.go index 3871417..b94c358 100644 --- a/save_img.go +++ b/save_img.go @@ -1,6 +1,7 @@ package wechatopen import ( + "context" "go.dtapp.net/gorequest" "log" "os" @@ -11,7 +12,7 @@ type SaveImgResponse struct { Name string } -func (c *Client) SaveImg(resp gorequest.Response, dir, saveName string) SaveImgResponse { +func (c *Client) SaveImg(ctx context.Context, 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/sns.component.jscode2session.go b/sns.component.jscode2session.go index fc95374..5fb0275 100644 --- a/sns.component.jscode2session.go +++ b/sns.component.jscode2session.go @@ -34,11 +34,11 @@ func newSnsComponentJsCode2sessionResult(result SnsComponentJsCode2sessionRespon func (c *Client) SnsComponentJsCode2session(ctx context.Context, jsCode string) *SnsComponentJsCode2sessionResult { // 参数 params := gorequest.NewParams() - 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 + 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(ctx) // 第三方平台的component_access_token // 请求 request, err := c.request(ctx, apiUrl+"/sns/component/jscode2session", params, http.MethodGet) // 定义 diff --git a/tcb.wxpaylist.go b/tcb.wxpaylist.go index f35c4b0..d35f4a7 100644 --- a/tcb.wxpaylist.go +++ b/tcb.wxpaylist.go @@ -37,7 +37,7 @@ func (c *Client) TckWxPayList(ctx context.Context) *TckWxPayListResult { // 参数 params := gorequest.NewParams() // 请求 - request, err := c.request(ctx, apiUrl+"/tcb/wxpaylist?access_token="+c.GetComponentAccessToken(), params, http.MethodPost) + request, err := c.request(ctx, apiUrl+"/tcb/wxpaylist?access_token="+c.GetComponentAccessToken(ctx), params, http.MethodPost) // 定义 var response TckWxPayListResponse err = json.Unmarshal(request.ResponseBody, &response) diff --git a/wxa.addtotemplate.go b/wxa.addtotemplate.go index 591f339..faf0999 100644 --- a/wxa.addtotemplate.go +++ b/wxa.addtotemplate.go @@ -32,7 +32,7 @@ func (c *Client) WxaAddToTemplate(ctx context.Context, draftId string, templateT params["draft_id"] = draftId params["template_type"] = templateType // 请求 - request, err := c.request(ctx, fmt.Sprintf(apiUrl+"/wxa/addtotemplate?access_token=%s", c.GetComponentAccessToken()), params, http.MethodPost) + request, err := c.request(ctx, fmt.Sprintf(apiUrl+"/wxa/addtotemplate?access_token=%s", c.GetComponentAccessToken(ctx)), 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 81558f0..12071ba 100644 --- a/wxa.bind_tester.go +++ b/wxa.bind_tester.go @@ -32,7 +32,7 @@ func (c *Client) WxaBindTester(ctx context.Context, wechatid string) *WxaBindTes params := gorequest.NewParams() params["wechatid"] = wechatid // 请求 - request, err := c.request(ctx, fmt.Sprintf(apiUrl+"/wxa/bind_tester?access_token=%s", c.GetAuthorizerAccessToken()), params, http.MethodPost) + request, err := c.request(ctx, fmt.Sprintf(apiUrl+"/wxa/bind_tester?access_token=%s", c.GetAuthorizerAccessToken(ctx)), 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 366e852..b468fdc 100644 --- a/wxa.business.getuserphonenumber.go +++ b/wxa.business.getuserphonenumber.go @@ -40,7 +40,7 @@ func (c *Client) WxaBusinessGetUserPhoneNumber(ctx context.Context, code string) params := gorequest.NewParams() params.Set("code", code) // 请求 - request, err := c.request(ctx, fmt.Sprintf(apiUrl+"/wxa/business/getuserphonenumber?access_token=%s", c.GetAuthorizerAccessToken()), params, http.MethodPost) + request, err := c.request(ctx, fmt.Sprintf(apiUrl+"/wxa/business/getuserphonenumber?access_token=%s", c.GetAuthorizerAccessToken(ctx)), params, http.MethodPost) // 定义 var response WxaBusinessGetUserPhoneNumberResponse err = json.Unmarshal(request.ResponseBody, &response) diff --git a/wxa.commit.go b/wxa.commit.go index 2d0050b..0fbf031 100644 --- a/wxa.commit.go +++ b/wxa.commit.go @@ -30,7 +30,7 @@ func (c *Client) WxaCommit(ctx context.Context, notMustParams ...gorequest.Param // 参数 params := gorequest.NewParamsWith(notMustParams...) // 请求 - request, err := c.request(ctx, fmt.Sprintf(apiUrl+"/wxa/commit?access_token=%s", c.GetAuthorizerAccessToken()), params, http.MethodPost) + request, err := c.request(ctx, fmt.Sprintf(apiUrl+"/wxa/commit?access_token=%s", c.GetAuthorizerAccessToken(ctx)), params, http.MethodPost) // 定义 var response WxaCommitResponse err = json.Unmarshal(request.ResponseBody, &response) diff --git a/wxa.deletetemplate.go b/wxa.deletetemplate.go index ba71eff..b5f7716 100644 --- a/wxa.deletetemplate.go +++ b/wxa.deletetemplate.go @@ -31,7 +31,7 @@ func (c *Client) WxaDeleteTemplate(ctx context.Context, templateId string) *WxaD params := gorequest.NewParams() params.Set("template_id", templateId) // 请求 - request, err := c.request(ctx, fmt.Sprintf(apiUrl+"/wxa/deletetemplate?access_token=%s", c.GetComponentAccessToken()), params, http.MethodPost) + request, err := c.request(ctx, fmt.Sprintf(apiUrl+"/wxa/deletetemplate?access_token=%s", c.GetComponentAccessToken(ctx)), 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 ce50e07..345dfba 100644 --- a/wxa.get_auditstatus.go +++ b/wxa.get_auditstatus.go @@ -35,7 +35,7 @@ func (c *Client) WxaGetAuditStatus(ctx context.Context, auditid int64) *WxaGetAu params := gorequest.NewParams() params.Set("auditid", auditid) // 请求 - request, err := c.request(ctx, fmt.Sprintf(apiUrl+"/wxa/get_auditstatus?access_token=%s", c.GetAuthorizerAccessToken()), params, http.MethodPost) + request, err := c.request(ctx, fmt.Sprintf(apiUrl+"/wxa/get_auditstatus?access_token=%s", c.GetAuthorizerAccessToken(ctx)), 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 7711fe9..85b3a8e 100644 --- a/wxa.get_category.go +++ b/wxa.get_category.go @@ -36,7 +36,7 @@ func newWxaGetCategoryResult(result WxaGetCategoryResponse, body []byte, http go // https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/category/get_category.html func (c *Client) WxaGetCategory(ctx context.Context) *WxaGetCategoryResult { // 请求 - request, err := c.request(ctx, fmt.Sprintf(apiUrl+"/wxa/get_category?access_token=%s", c.GetAuthorizerAccessToken()), map[string]interface{}{}, http.MethodGet) + request, err := c.request(ctx, fmt.Sprintf(apiUrl+"/wxa/get_category?access_token=%s", c.GetAuthorizerAccessToken(ctx)), 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 1b751e4..dd7cd76 100644 --- a/wxa.get_effective_domain.go +++ b/wxa.get_effective_domain.go @@ -54,7 +54,7 @@ func (c *Client) WxaGetEffectiveDomain(ctx context.Context, notMustParams ...gor // 参数 params := gorequest.NewParamsWith(notMustParams...) // 请求 - request, err := c.request(ctx, fmt.Sprintf(apiUrl+"/wxa/get_effective_domain?access_token=%s", c.GetAuthorizerAccessToken()), params, http.MethodPost) + request, err := c.request(ctx, fmt.Sprintf(apiUrl+"/wxa/get_effective_domain?access_token=%s", c.GetAuthorizerAccessToken(ctx)), 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 b476282..756e636 100644 --- a/wxa.get_latest_auditstatus.go +++ b/wxa.get_latest_auditstatus.go @@ -32,7 +32,7 @@ func newWxaGetLatestAuditStatusResult(result WxaGetLatestAuditStatusResponse, bo // https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/code/get_auditstatus.html func (c *Client) WxaGetLatestAuditStatus(ctx context.Context) *WxaGetLatestAuditStatusResult { // 请求 - request, err := c.request(ctx, fmt.Sprintf(apiUrl+"/wxa/get_latest_auditstatus?access_token=%s", c.GetAuthorizerAccessToken()), map[string]interface{}{}, http.MethodPost) + request, err := c.request(ctx, fmt.Sprintf(apiUrl+"/wxa/get_latest_auditstatus?access_token=%s", c.GetAuthorizerAccessToken(ctx)), 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 5040d0f..58a2c74 100644 --- a/wxa.get_page.go +++ b/wxa.get_page.go @@ -29,7 +29,7 @@ func newWxaGetPageResult(result WxaGetPageResponse, body []byte, http gorequest. // https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/code/get_page.html func (c *Client) WxaGetPage(ctx context.Context) *WxaGetPageResult { // 请求 - request, err := c.request(ctx, fmt.Sprintf(apiUrl+"/wxa/get_page?access_token=%s", c.GetAuthorizerAccessToken()), map[string]interface{}{}, http.MethodGet) + request, err := c.request(ctx, fmt.Sprintf(apiUrl+"/wxa/get_page?access_token=%s", c.GetAuthorizerAccessToken(ctx)), 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 8a60df8..613465c 100644 --- a/wxa.get_qrcode.go +++ b/wxa.get_qrcode.go @@ -33,7 +33,7 @@ func (c *Client) WxaGetQrcode(ctx context.Context, path string) *WxaGetQrcodeRes params["path"] = path // 指定二维码扫码后直接进入指定页面并可同时带上参数) } // 请求 - request, err := c.request(ctx, fmt.Sprintf(apiUrl+"/wxa/get_qrcode?access_token=%s", c.GetAuthorizerAccessToken()), params, http.MethodGet) + request, err := c.request(ctx, fmt.Sprintf(apiUrl+"/wxa/get_qrcode?access_token=%s", c.GetAuthorizerAccessToken(ctx)), params, http.MethodGet) // 定义 var response WxaGetQrcodeResponse err = json.Unmarshal(request.ResponseBody, &response) diff --git a/wxa.gettemplatedraftlist.go b/wxa.gettemplatedraftlist.go index 931895a..e8947aa 100644 --- a/wxa.gettemplatedraftlist.go +++ b/wxa.gettemplatedraftlist.go @@ -38,7 +38,7 @@ func newWxaGetTemplateDraftListResult(result WxaGetTemplateDraftListResponse, bo // https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/ThirdParty/code_template/gettemplatedraftlist.html func (c *Client) WxaGetTemplateDraftList(ctx context.Context) *WxaGetTemplateDraftListResult { // 请求 - request, err := c.request(ctx, fmt.Sprintf(apiUrl+"/wxa/gettemplatedraftlist?access_token=%s", c.GetComponentAccessToken()), map[string]interface{}{}, http.MethodGet) + request, err := c.request(ctx, fmt.Sprintf(apiUrl+"/wxa/gettemplatedraftlist?access_token=%s", c.GetComponentAccessToken(ctx)), 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 ef49651..90fa6fb 100644 --- a/wxa.gettemplatelist.go +++ b/wxa.gettemplatelist.go @@ -39,7 +39,7 @@ func newWxaGetTemplateListResult(result WxaGetTemplateListResponse, body []byte, // https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/ThirdParty/code_template/gettemplatelist.html func (c *Client) WxaGetTemplateList(ctx context.Context) *WxaGetTemplateListResult { // 请求 - request, err := c.request(ctx, fmt.Sprintf(apiUrl+"/wxa/gettemplatelist?access_token=%s", c.GetComponentAccessToken()), map[string]interface{}{}, http.MethodGet) + request, err := c.request(ctx, fmt.Sprintf(apiUrl+"/wxa/gettemplatelist?access_token=%s", c.GetComponentAccessToken(ctx)), 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 c568eab..79afcbf 100644 --- a/wxa.getversioninfo.go +++ b/wxa.getversioninfo.go @@ -38,7 +38,7 @@ 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 (c *Client) WxaGetVersionInfo(ctx context.Context) *WxaGetVersionInfoResult { - accessToken := c.GetAuthorizerAccessToken() + accessToken := c.GetAuthorizerAccessToken(ctx) if accessToken == "" { return newWxaGetVersionInfoResult(WxaGetVersionInfoResponse{}, nil, gorequest.Response{}, errors.New("访问令牌为空")) } diff --git a/wxa.getwxacodeunlimit.go b/wxa.getwxacodeunlimit.go index 94d57b0..51b5727 100644 --- a/wxa.getwxacodeunlimit.go +++ b/wxa.getwxacodeunlimit.go @@ -32,7 +32,7 @@ func (c *Client) WxaGetWxaCodeUnLimit(ctx context.Context, notMustParams ...gore // 参数 params := gorequest.NewParamsWith(notMustParams...) // 请求 - request, err := c.request(ctx, fmt.Sprintf(apiUrl+"/wxa/getwxacodeunlimit?access_token=%s", c.GetAuthorizerAccessToken()), params, http.MethodPost) + request, err := c.request(ctx, fmt.Sprintf(apiUrl+"/wxa/getwxacodeunlimit?access_token=%s", c.GetAuthorizerAccessToken(ctx)), params, http.MethodPost) // 定义 var response WxaGetWxaCodeUnLimitResponse err = json.Unmarshal(request.ResponseBody, &response) diff --git a/wxa.memberauth.go b/wxa.memberauth.go index 0a13f93..91b4740 100644 --- a/wxa.memberauth.go +++ b/wxa.memberauth.go @@ -31,7 +31,7 @@ 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 (c *Client) WxaMemberAuth(ctx context.Context) *WxaMemberAuthResult { - accessToken := c.GetAuthorizerAccessToken() + accessToken := c.GetAuthorizerAccessToken(ctx) if accessToken == "" { return newWxaMemberAuthResult(WxaMemberAuthResponse{}, nil, gorequest.Response{}, errors.New("访问令牌为空")) } diff --git a/wxa.modify_domain.go b/wxa.modify_domain.go index b967403..1ac052a 100644 --- a/wxa.modify_domain.go +++ b/wxa.modify_domain.go @@ -43,7 +43,7 @@ func (c *Client) WxaModifyDomain(ctx context.Context, notMustParams ...gorequest // 参数 params := gorequest.NewParamsWith(notMustParams...) // 请求 - request, err := c.request(ctx, fmt.Sprintf(apiUrl+"/wxa/modify_domain?access_token=%s", c.GetAuthorizerAccessToken()), params, http.MethodPost) + request, err := c.request(ctx, fmt.Sprintf(apiUrl+"/wxa/modify_domain?access_token=%s", c.GetAuthorizerAccessToken(ctx)), 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 abb0381..d9b9d21 100644 --- a/wxa.modify_domain_directly.go +++ b/wxa.modify_domain_directly.go @@ -30,7 +30,7 @@ func (c *Client) WxaModifyDomainDirectly(ctx context.Context, notMustParams ...g // 参数 params := gorequest.NewParamsWith(notMustParams...) // 请求 - request, err := c.request(ctx, fmt.Sprintf(apiUrl+"/wxa/modify_domain_directly?access_token=%s", c.GetAuthorizerAccessToken()), params, http.MethodPost) + request, err := c.request(ctx, fmt.Sprintf(apiUrl+"/wxa/modify_domain_directly?access_token=%s", c.GetAuthorizerAccessToken(ctx)), params, http.MethodPost) // 定义 var response WxaModifyDomainDirectlyResponse err = json.Unmarshal(request.ResponseBody, &response) diff --git a/wxa.release.go b/wxa.release.go index b514677..6ef4d12 100644 --- a/wxa.release.go +++ b/wxa.release.go @@ -30,7 +30,7 @@ func (c *Client) WxaRelease(ctx context.Context) *WxaReleaseResult { // 参数 params := gorequest.NewParams() // 请求 - request, err := c.request(ctx, fmt.Sprintf(apiUrl+"/wxa/release?access_token=%s", c.GetAuthorizerAccessToken()), params, http.MethodPost) + request, err := c.request(ctx, fmt.Sprintf(apiUrl+"/wxa/release?access_token=%s", c.GetAuthorizerAccessToken(ctx)), 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 649c4da..bb7b7c8 100644 --- a/wxa.security.apply_privacy_interface.go +++ b/wxa.security.apply_privacy_interface.go @@ -31,7 +31,7 @@ func (c *Client) WxaSecurityApplyPrivacyInterface(ctx context.Context, notMustPa // 参数 params := gorequest.NewParamsWith(notMustParams...) // 请求 - request, err := c.request(ctx, fmt.Sprintf(apiUrl+"/wxa/security/apply_privacy_interface?access_token=%s", c.GetAuthorizerAccessToken()), params, http.MethodPost) + request, err := c.request(ctx, fmt.Sprintf(apiUrl+"/wxa/security/apply_privacy_interface?access_token=%s", c.GetAuthorizerAccessToken(ctx)), 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 be19828..e44312b 100644 --- a/wxa.security.get_privacy_interface.go +++ b/wxa.security.get_privacy_interface.go @@ -41,7 +41,7 @@ func (c *Client) WxaSecurityGetPrivacyInterface(ctx context.Context) *WxaSecurit // 参数 params := gorequest.NewParams() // 请求 - request, err := c.request(ctx, fmt.Sprintf(apiUrl+"/wxa/security/get_privacy_interface?access_token=%s", c.GetAuthorizerAccessToken()), params, http.MethodGet) + request, err := c.request(ctx, fmt.Sprintf(apiUrl+"/wxa/security/get_privacy_interface?access_token=%s", c.GetAuthorizerAccessToken(ctx)), 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 ba4fa7e..4b3bd16 100644 --- a/wxa.submit_audit.go +++ b/wxa.submit_audit.go @@ -31,7 +31,7 @@ func (c *Client) WxaSubmitAudit(ctx context.Context, notMustParams ...gorequest. // 参数 params := gorequest.NewParamsWith(notMustParams...) // 请求 - request, err := c.request(ctx, fmt.Sprintf(apiUrl+"/wxa/submit_audit?access_token=%s", c.GetAuthorizerAccessToken()), params, http.MethodPost) + request, err := c.request(ctx, fmt.Sprintf(apiUrl+"/wxa/submit_audit?access_token=%s", c.GetAuthorizerAccessToken(ctx)), 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 d551a00..f46546c 100644 --- a/wxa.unbind_tester.go +++ b/wxa.unbind_tester.go @@ -34,7 +34,7 @@ func (c *Client) WxaUnbindTester(ctx context.Context, wechatid, userstr string) } params["userstr"] = userstr // 请求 - request, err := c.request(ctx, fmt.Sprintf(apiUrl+"/wxa/unbind_tester?access_token=%s", c.GetAuthorizerAccessToken()), params, http.MethodPost) + request, err := c.request(ctx, fmt.Sprintf(apiUrl+"/wxa/unbind_tester?access_token=%s", c.GetAuthorizerAccessToken(ctx)), params, http.MethodPost) // 定义 var response WxaUnbindTesterResponse err = json.Unmarshal(request.ResponseBody, &response)