- update request
continuous-integration/drone/push Build is failing Details
continuous-integration/drone/tag Build is failing Details

master v1.0.6
李光春 2 years ago
parent 61aa7fbac9
commit bb4857963d

@ -1,6 +1,7 @@
package wechatopen
import (
"context"
"encoding/json"
"fmt"
"go.dtapp.net/gorequest"
@ -55,9 +56,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 (c *Client) CgiBinAccountGetAccountBasicInfo() *CgiBinAccountGetAccountBasicInfoResult {
func (c *Client) CgiBinAccountGetAccountBasicInfo(ctx context.Context) *CgiBinAccountGetAccountBasicInfoResult {
// 请求
request, err := c.request(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()), map[string]interface{}{}, http.MethodGet)
// 定义
var response CgiBinAccountGetAccountBasicInfoResponse
err = json.Unmarshal(request.ResponseBody, &response)

@ -1,6 +1,7 @@
package wechatopen
import (
"context"
"encoding/json"
"fmt"
"go.dtapp.net/gorequest"
@ -27,7 +28,7 @@ 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 (c *Client) CgiBinComponentApiAuthorizerToken(authorizerRefreshToken string) *CgiBinComponentApiAuthorizerTokenResult {
func (c *Client) CgiBinComponentApiAuthorizerToken(ctx context.Context, authorizerRefreshToken string) *CgiBinComponentApiAuthorizerTokenResult {
// 参数
param := gorequest.NewParams()
param["component_appid"] = c.config.ComponentAppId // 第三方平台 appid
@ -35,7 +36,7 @@ func (c *Client) CgiBinComponentApiAuthorizerToken(authorizerRefreshToken string
param["authorizer_refresh_token"] = authorizerRefreshToken // 授权码, 会在授权成功时返回给第三方平台
params := gorequest.NewParamsWith(param)
// 请求
request, err := c.request(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()), params, http.MethodPost)
// 定义
var response CgiBinComponentApiAuthorizerTokenResponse
err = json.Unmarshal(request.ResponseBody, &response)

@ -1,6 +1,7 @@
package wechatopen
import (
"context"
"encoding/json"
"go.dtapp.net/gorequest"
"net/http"
@ -24,7 +25,7 @@ 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 (c *Client) CgiBinComponentApiComponentToken() *CgiBinComponentApiComponentTokenResult {
func (c *Client) CgiBinComponentApiComponentToken(ctx context.Context) *CgiBinComponentApiComponentTokenResult {
// 参数
param := gorequest.NewParams()
param["component_appid"] = c.config.ComponentAppId // 第三方平台 appid
@ -32,7 +33,7 @@ func (c *Client) CgiBinComponentApiComponentToken() *CgiBinComponentApiComponent
param["component_verify_ticket"] = c.GetComponentVerifyTicket() // 微信后台推送的 ticket
params := gorequest.NewParamsWith(param)
// 请求
request, err := c.request(apiUrl+"/cgi-bin/component/api_component_token", params, http.MethodPost)
request, err := c.request(ctx, apiUrl+"/cgi-bin/component/api_component_token", params, http.MethodPost)
// 定义
var response CgiBinComponentApiComponentTokenResponse
err = json.Unmarshal(request.ResponseBody, &response)

@ -1,6 +1,7 @@
package wechatopen
import (
"context"
"encoding/json"
"fmt"
"go.dtapp.net/gorequest"
@ -25,13 +26,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 (c *Client) CgiBinComponentApiCreatePreAuthCoden() *CgiBinComponentApiCreatePreAuthCodenResult {
func (c *Client) CgiBinComponentApiCreatePreAuthCoden(ctx context.Context) *CgiBinComponentApiCreatePreAuthCodenResult {
// 参数
param := gorequest.NewParams()
param["component_appid"] = c.config.ComponentAppId // 第三方平台 appid
params := gorequest.NewParamsWith(param)
// 请求
request, err := c.request(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()), params, http.MethodPost)
// 定义
var response CgiBinComponentApiCreatePreAuthCodenResponse
err = json.Unmarshal(request.ResponseBody, &response)

@ -1,6 +1,7 @@
package wechatopen
import (
"context"
"encoding/json"
"fmt"
"go.dtapp.net/gorequest"
@ -83,14 +84,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 (c *Client) CgiBinComponentApiGetAuthorizerInfo() *CgiBinComponentApiGetAuthorizerInfoResult {
func (c *Client) CgiBinComponentApiGetAuthorizerInfo(ctx context.Context) *CgiBinComponentApiGetAuthorizerInfoResult {
// 参数
param := gorequest.NewParams()
param["component_appid"] = c.config.ComponentAppId // 第三方平台 appid
param["authorizer_appid"] = c.config.AuthorizerAppid // 授权方 appid
params := gorequest.NewParamsWith(param)
// 请求
request, err := c.request(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()), params, http.MethodPost)
// 定义
var response CgiBinComponentApiGetAuthorizerInfoResponse
err = json.Unmarshal(request.ResponseBody, &response)

@ -1,6 +1,7 @@
package wechatopen
import (
"context"
"encoding/json"
"fmt"
"go.dtapp.net/gorequest"
@ -39,14 +40,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 (c *Client) CgiBinComponentApiQueryAuth(authorizationCode string) *CgiBinComponentApiQueryAuthResult {
func (c *Client) CgiBinComponentApiQueryAuth(ctx context.Context, authorizationCode string) *CgiBinComponentApiQueryAuthResult {
// 参数
param := gorequest.NewParams()
param["component_appid"] = c.config.ComponentAppId // 第三方平台 appid
param["authorization_code"] = authorizationCode // 授权码, 会在授权成功时返回给第三方平台
params := gorequest.NewParamsWith(param)
// 请求
request, err := c.request(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()), params, http.MethodPost)
// 定义
var response CgiBinComponentApiQueryAuthResponse
err = json.Unmarshal(request.ResponseBody, &response)

@ -1,6 +1,7 @@
package wechatopen
import (
"context"
"encoding/json"
"go.dtapp.net/gorequest"
"net/http"
@ -26,14 +27,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 (c *Client) CgiBinComponentApiStartPushTicket() *CgiBinComponentApiStartPushTicketResult {
func (c *Client) CgiBinComponentApiStartPushTicket(ctx context.Context) *CgiBinComponentApiStartPushTicketResult {
// 参数
param := gorequest.NewParams()
param["component_appid"] = c.config.ComponentAppId // 平台型第三方平台的appid
param["component_secret"] = c.config.ComponentAppSecret // 平台型第三方平台的APPSECRET
params := gorequest.NewParamsWith(param)
// 请求
request, err := c.request(apiUrl+"/cgi-bin/component/api_start_push_ticket", params, http.MethodPost)
request, err := c.request(ctx, apiUrl+"/cgi-bin/component/api_start_push_ticket", params, http.MethodPost)
// 定义
var response CgiBinComponentApiStartPushTicketResponse
err = json.Unmarshal(request.ResponseBody, &response)

@ -1,6 +1,7 @@
package wechatopen
import (
"context"
"encoding/json"
"fmt"
"go.dtapp.net/gorequest"
@ -58,12 +59,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 (c *Client) CgiBinComponentGetPrivacySetting(privacyVer int) *CgiBinComponentGetPrivacySettingResult {
func (c *Client) CgiBinComponentGetPrivacySetting(ctx context.Context, privacyVer int) *CgiBinComponentGetPrivacySettingResult {
// 参数
params := gorequest.NewParams()
params["privacy_ver"] = privacyVer
// 请求
request, err := c.request(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()), params, http.MethodPost)
// 定义
var response CgiBinComponentGetPrivacySettingResponse
err = json.Unmarshal(request.ResponseBody, &response)

@ -1,6 +1,7 @@
package wechatopen
import (
"context"
"encoding/json"
"fmt"
"go.dtapp.net/gorequest"
@ -25,11 +26,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 (c *Client) CgiBinComponentSetPrivacySetting(notMustParams ...gorequest.Params) *CgiBinComponentSetPrivacySettingResult {
func (c *Client) CgiBinComponentSetPrivacySetting(ctx context.Context, notMustParams ...gorequest.Params) *CgiBinComponentSetPrivacySettingResult {
// 参数
params := gorequest.NewParamsWith(notMustParams...)
// 请求
request, err := c.request(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()), params, http.MethodPost)
// 定义
var response CgiBinComponentSetPrivacySettingResponse
err = json.Unmarshal(request.ResponseBody, &response)

@ -1,6 +1,7 @@
package wechatopen
import (
"context"
"encoding/json"
"fmt"
"go.dtapp.net/gorequest"
@ -24,9 +25,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 (c *Client) CgiBinGetApiDomainIp(componentAccessToken string) *GetCallBackIpResult {
func (c *Client) CgiBinGetApiDomainIp(ctx context.Context, componentAccessToken string) *GetCallBackIpResult {
// 请求
request, err := c.request(fmt.Sprintf(apiUrl+"/cgi-bin/get_api_domain_ip?access_token=%s", componentAccessToken), map[string]interface{}{}, http.MethodGet)
request, err := c.request(ctx, fmt.Sprintf(apiUrl+"/cgi-bin/get_api_domain_ip?access_token=%s", componentAccessToken), map[string]interface{}{}, http.MethodGet)
// 定义
var response GetCallBackIpResponse
err = json.Unmarshal(request.ResponseBody, &response)

@ -1,6 +1,7 @@
package wechatopen
import (
"context"
"encoding/json"
"fmt"
"go.dtapp.net/gorequest"
@ -26,13 +27,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 (c *Client) CgiBinShortUrl(longUrl string) *CgiBinShortUrlResult {
func (c *Client) CgiBinShortUrl(ctx context.Context, longUrl string) *CgiBinShortUrlResult {
// 参数
params := gorequest.NewParams()
params["action"] = "long2short" // 此处填long2short代表长链接转短链接
params["long_url"] = longUrl // 需要转换的长链接支持http://、https://、weixin://wxpay 格式的url
// 请求
request, err := c.request(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()), params, http.MethodPost)
// 定义
var response CgiBinShortUrlResponse
err = json.Unmarshal(request.ResponseBody, &response)

@ -1,6 +1,7 @@
package wechatopen
import (
"context"
"encoding/json"
"fmt"
"go.dtapp.net/gorequest"
@ -25,11 +26,11 @@ func newCgiBinWxOpenQrCodeJumpAddResult(result CgiBinWxOpenQrCodeJumpAddResponse
// CgiBinWxOpenQrCodeJumpAdd 增加或修改二维码规则
// https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/qrcode/qrcodejumpadd.html
func (c *Client) CgiBinWxOpenQrCodeJumpAdd(notMustParams ...gorequest.Params) *CgiBinWxOpenQrCodeJumpAddResult {
func (c *Client) CgiBinWxOpenQrCodeJumpAdd(ctx context.Context, notMustParams ...gorequest.Params) *CgiBinWxOpenQrCodeJumpAddResult {
// 参数
params := gorequest.NewParamsWith(notMustParams...)
// 请求
request, err := c.request(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()), params, http.MethodPost)
// 定义
var response CgiBinWxOpenQrCodeJumpAddResponse
err = json.Unmarshal(request.ResponseBody, &response)

@ -1,6 +1,7 @@
package wechatopen
import (
"context"
"encoding/json"
"fmt"
"go.dtapp.net/gorequest"
@ -25,12 +26,12 @@ func newCgiBinWxOpenQrCodeJumpDeleteResult(result CgiBinWxOpenQrCodeJumpDeleteRe
// CgiBinWxOpenQrCodeJumpDelete 删除已设置的二维码规则
// https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/qrcode/qrcodejumpdelete.html
func (c *Client) CgiBinWxOpenQrCodeJumpDelete(prefix string) *CgiBinWxOpenQrCodeJumpDeleteResult {
func (c *Client) CgiBinWxOpenQrCodeJumpDelete(ctx context.Context, prefix string) *CgiBinWxOpenQrCodeJumpDeleteResult {
// 参数
params := gorequest.NewParams()
params["prefix"] = prefix
// 请求
request, err := c.request(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()), params, http.MethodPost)
// 定义
var response CgiBinWxOpenQrCodeJumpDeleteResponse
err = json.Unmarshal(request.ResponseBody, &response)

@ -1,6 +1,7 @@
package wechatopen
import (
"context"
"encoding/json"
"fmt"
"go.dtapp.net/gorequest"
@ -27,11 +28,11 @@ func newCgiBinWxOpenQrCodeJumpDownloadResult(result CgiBinWxOpenQrCodeJumpDownlo
// CgiBinWxOpenQrCodeJumpDownload 获取校验文件名称及内容
// https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/qrcode/qrcodejumpdownload.html
func (c *Client) CgiBinWxOpenQrCodeJumpDownload() *CgiBinWxOpenQrCodeJumpDownloadResult {
func (c *Client) CgiBinWxOpenQrCodeJumpDownload(ctx context.Context) *CgiBinWxOpenQrCodeJumpDownloadResult {
// 参数
params := gorequest.NewParams()
// 请求
request, err := c.request(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()), params, http.MethodPost)
// 定义
var response CgiBinWxOpenQrCodeJumpDownloadResponse
err = json.Unmarshal(request.ResponseBody, &response)

@ -1,6 +1,7 @@
package wechatopen
import (
"context"
"encoding/json"
"fmt"
"go.dtapp.net/gorequest"
@ -36,11 +37,11 @@ func newCgiBinWxOpenQrCodeJumpGetResult(result CgiBinWxOpenQrCodeJumpGetResponse
// CgiBinWxOpenQrCodeJumpGet 获取已设置的二维码规则
// https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/qrcode/qrcodejumpadd.html
func (c *Client) CgiBinWxOpenQrCodeJumpGet() *CgiBinWxOpenQrCodeJumpGetResult {
func (c *Client) CgiBinWxOpenQrCodeJumpGet(ctx context.Context) *CgiBinWxOpenQrCodeJumpGetResult {
// 参数
params := gorequest.NewParams()
// 请求
request, err := c.request(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()), params, http.MethodPost)
// 定义
var response CgiBinWxOpenQrCodeJumpGetResponse
err = json.Unmarshal(request.ResponseBody, &response)

@ -1,6 +1,7 @@
package wechatopen
import (
"context"
"encoding/json"
"fmt"
"go.dtapp.net/gorequest"
@ -25,12 +26,12 @@ func newCgiBinWxOpenQrCodeJumpPublishResult(result CgiBinWxOpenQrCodeJumpPublish
// CgiBinWxOpenQrCodeJumpPublish 发布已设置的二维码规则
// https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/qrcode/qrcodejumppublish.html
func (c *Client) CgiBinWxOpenQrCodeJumpPublish(prefix string) *CgiBinWxOpenQrCodeJumpPublishResult {
func (c *Client) CgiBinWxOpenQrCodeJumpPublish(ctx context.Context, prefix string) *CgiBinWxOpenQrCodeJumpPublishResult {
// 参数
params := gorequest.NewParams()
params["prefix"] = prefix
// 请求
request, err := c.request(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()), params, http.MethodPost)
// 定义
var response CgiBinWxOpenQrCodeJumpPublishResponse
err = json.Unmarshal(request.ResponseBody, &response)

@ -8,4 +8,4 @@ const (
logTable = "wechatopen"
)
const Version = "1.0.5"
const Version = "1.0.6"

@ -4,8 +4,8 @@ go 1.19
require (
github.com/mitchellh/mapstructure v1.5.0
go.dtapp.net/dorm v1.0.14
go.dtapp.net/golog v1.0.21
go.dtapp.net/dorm v1.0.16
go.dtapp.net/golog v1.0.22
go.dtapp.net/gorequest v1.0.24
gorm.io/gorm v1.23.8
)
@ -70,14 +70,14 @@ require (
go.dtapp.net/gotime v1.0.5 // indirect
go.dtapp.net/goxml v1.0.1 // indirect
go.mongodb.org/mongo-driver v1.10.1 // indirect
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/multierr v1.8.0 // indirect
go.uber.org/zap v1.22.0 // indirect
golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa // indirect
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect
golang.org/x/net v0.0.0-20220809184613-07c6da5e1ced // indirect
golang.org/x/net v0.0.0-20220811182439-13a9a731de15 // indirect
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4 // indirect
golang.org/x/sys v0.0.0-20220808155132-1c4a2a72c664 // indirect
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab // indirect
golang.org/x/text v0.3.7 // indirect
google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect

@ -507,12 +507,16 @@ github.com/zenazn/goji v0.9.0/go.mod h1:7S9M489iMyHBNxwZnk9/EHS098H4/F6TATF2mIxt
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/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=
go.dtapp.net/gorandom v1.0.1/go.mod h1:ZPdgalKpvFV/ATQqR0k4ns/F/IpITAZpx6WkWirr5Y8=
go.dtapp.net/gorequest v1.0.24 h1:N2RJOpCXPWbsjfQ8iYJI1EYC2se3I4QhK1l94DSJsuE=
@ -537,6 +541,8 @@ 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=
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4=
@ -609,6 +615,8 @@ golang.org/x/net v0.0.0-20210610132358-84b48f89b13b/go.mod h1:9nx3DQGgdP8bBQD5qx
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=
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
@ -655,6 +663,8 @@ golang.org/x/sys v0.0.0-20211210111614-af8b64212486/go.mod h1:oPkhp1MJrh7nUepCBc
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=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=

@ -1,8 +1,11 @@
package wechatopen
import "go.dtapp.net/gorequest"
import (
"context"
"go.dtapp.net/gorequest"
)
func (c *Client) request(url string, params map[string]interface{}, method string) (resp gorequest.Response, err error) {
func (c *Client) request(ctx context.Context, url string, params map[string]interface{}, method string) (resp gorequest.Response, err error) {
// 创建请求
client := c.client
@ -27,7 +30,7 @@ func (c *Client) request(url string, params map[string]interface{}, method strin
// 日志
if c.config.PgsqlDb != nil {
go c.log.GormMiddleware(request, Version)
go c.log.GormMiddleware(ctx, request, Version)
}
if c.config.MongoDb != nil {
go c.log.MongoMiddleware(request)

@ -1,6 +1,7 @@
package wechatopen
import (
"context"
"crypto/aes"
"crypto/cipher"
"encoding/base64"
@ -30,7 +31,7 @@ func newSnsComponentJsCode2sessionResult(result SnsComponentJsCode2sessionRespon
// SnsComponentJsCode2session 小程序登录
// https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/others/WeChat_login.html
func (c *Client) SnsComponentJsCode2session(jsCode string) *SnsComponentJsCode2sessionResult {
func (c *Client) SnsComponentJsCode2session(ctx context.Context, jsCode string) *SnsComponentJsCode2sessionResult {
// 参数
params := gorequest.NewParams()
params["appid"] = c.config.AuthorizerAppid // 小程序的 appId
@ -39,7 +40,7 @@ func (c *Client) SnsComponentJsCode2session(jsCode string) *SnsComponentJsCode2s
params["component_appid"] = c.config.ComponentAppId // 第三方平台 appid
params["component_access_token"] = c.GetComponentAccessToken() // 第三方平台的component_access_token
// 请求
request, err := c.request(apiUrl+"/sns/component/jscode2session", params, http.MethodGet)
request, err := c.request(ctx, apiUrl+"/sns/component/jscode2session", params, http.MethodGet)
// 定义
var response SnsComponentJsCode2sessionResponse
err = json.Unmarshal(request.ResponseBody, &response)

@ -1,6 +1,7 @@
package wechatopen
import (
"context"
"encoding/json"
"go.dtapp.net/gorequest"
"net/http"
@ -32,11 +33,11 @@ func newTckWxPayListResult(result TckWxPayListResponse, body []byte, http gorequ
// TckWxPayList 获取授权绑定的商户号列表
// https://developers.weixin.qq.com/doc/oplatform/openApi/OpenApiDoc/cloudbase-common/wechatpay/getWechatPayList.html
func (c *Client) TckWxPayList() *TckWxPayListResult {
func (c *Client) TckWxPayList(ctx context.Context) *TckWxPayListResult {
// 参数
params := gorequest.NewParams()
// 请求
request, err := c.request(apiUrl+"/tcb/wxpaylist?access_token="+c.GetComponentAccessToken(), params, http.MethodPost)
request, err := c.request(ctx, apiUrl+"/tcb/wxpaylist?access_token="+c.GetComponentAccessToken(), params, http.MethodPost)
// 定义
var response TckWxPayListResponse
err = json.Unmarshal(request.ResponseBody, &response)

@ -1,6 +1,7 @@
package wechatopen
import (
"context"
"encoding/json"
"fmt"
"go.dtapp.net/gorequest"
@ -25,13 +26,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 (c *Client) WxaAddToTemplate(draftId string, templateType int) *WxaAddToTemplateResult {
func (c *Client) WxaAddToTemplate(ctx context.Context, draftId string, templateType int) *WxaAddToTemplateResult {
// 参数
params := gorequest.NewParams()
params["draft_id"] = draftId
params["template_type"] = templateType
// 请求
request, err := c.request(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()), params, http.MethodPost)
// 定义
var response WxaAddToTemplateResponse
err = json.Unmarshal(request.ResponseBody, &response)

@ -1,6 +1,7 @@
package wechatopen
import (
"context"
"encoding/json"
"fmt"
"go.dtapp.net/gorequest"
@ -26,12 +27,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 (c *Client) WxaBindTester(wechatid string) *WxaBindTesterResult {
func (c *Client) WxaBindTester(ctx context.Context, wechatid string) *WxaBindTesterResult {
// 参数
params := gorequest.NewParams()
params["wechatid"] = wechatid
// 请求
request, err := c.request(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()), params, http.MethodPost)
// 定义
var response WxaBindTesterResponse
err = json.Unmarshal(request.ResponseBody, &response)

@ -1,6 +1,7 @@
package wechatopen
import (
"context"
"encoding/json"
"fmt"
"go.dtapp.net/gorequest"
@ -34,12 +35,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 (c *Client) WxaBusinessGetUserPhoneNumber(code string) *WxaBusinessGetUserPhoneNumberResult {
func (c *Client) WxaBusinessGetUserPhoneNumber(ctx context.Context, code string) *WxaBusinessGetUserPhoneNumberResult {
// 参数
params := gorequest.NewParams()
params.Set("code", code)
// 请求
request, err := c.request(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()), params, http.MethodPost)
// 定义
var response WxaBusinessGetUserPhoneNumberResponse
err = json.Unmarshal(request.ResponseBody, &response)

@ -1,6 +1,7 @@
package wechatopen
import (
"context"
"encoding/json"
"fmt"
"go.dtapp.net/gorequest"
@ -25,11 +26,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 (c *Client) WxaCommit(notMustParams ...gorequest.Params) *WxaCommitResult {
func (c *Client) WxaCommit(ctx context.Context, notMustParams ...gorequest.Params) *WxaCommitResult {
// 参数
params := gorequest.NewParamsWith(notMustParams...)
// 请求
request, err := c.request(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()), params, http.MethodPost)
// 定义
var response WxaCommitResponse
err = json.Unmarshal(request.ResponseBody, &response)

@ -1,6 +1,7 @@
package wechatopen
import (
"context"
"encoding/json"
"fmt"
"go.dtapp.net/gorequest"
@ -25,12 +26,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 (c *Client) WxaDeleteTemplate(templateId string) *WxaDeleteTemplateResult {
func (c *Client) WxaDeleteTemplate(ctx context.Context, templateId string) *WxaDeleteTemplateResult {
// 参数
params := gorequest.NewParams()
params.Set("template_id", templateId)
// 请求
request, err := c.request(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()), params, http.MethodPost)
// 定义
var response WxaDeleteTemplateResponse
err = json.Unmarshal(request.ResponseBody, &response)

@ -1,6 +1,7 @@
package wechatopen
import (
"context"
"encoding/json"
"fmt"
"go.dtapp.net/gorequest"
@ -29,12 +30,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 (c *Client) WxaGetAuditStatus(auditid int64) *WxaGetAuditStatusResult {
func (c *Client) WxaGetAuditStatus(ctx context.Context, auditid int64) *WxaGetAuditStatusResult {
// 参数
params := gorequest.NewParams()
params.Set("auditid", auditid)
// 请求
request, err := c.request(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()), params, http.MethodPost)
// 定义
var response WxaGetAuditStatusResponse
err = json.Unmarshal(request.ResponseBody, &response)

@ -1,6 +1,7 @@
package wechatopen
import (
"context"
"encoding/json"
"fmt"
"go.dtapp.net/gorequest"
@ -33,9 +34,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 (c *Client) WxaGetCategory() *WxaGetCategoryResult {
func (c *Client) WxaGetCategory(ctx context.Context) *WxaGetCategoryResult {
// 请求
request, err := c.request(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()), map[string]interface{}{}, http.MethodGet)
// 定义
var response WxaGetCategoryResponse
err = json.Unmarshal(request.ResponseBody, &response)

@ -1,6 +1,7 @@
package wechatopen
import (
"context"
"encoding/json"
"fmt"
"go.dtapp.net/gorequest"
@ -49,11 +50,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 (c *Client) WxaGetEffectiveDomain(notMustParams ...gorequest.Params) *WxaGetEffectiveDomainResult {
func (c *Client) WxaGetEffectiveDomain(ctx context.Context, notMustParams ...gorequest.Params) *WxaGetEffectiveDomainResult {
// 参数
params := gorequest.NewParamsWith(notMustParams...)
// 请求
request, err := c.request(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()), params, http.MethodPost)
// 定义
var response WxaGetEffectiveDomainResponse
err = json.Unmarshal(request.ResponseBody, &response)

@ -1,6 +1,7 @@
package wechatopen
import (
"context"
"encoding/json"
"fmt"
"go.dtapp.net/gorequest"
@ -29,9 +30,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 (c *Client) WxaGetLatestAuditStatus() *WxaGetLatestAuditStatusResult {
func (c *Client) WxaGetLatestAuditStatus(ctx context.Context) *WxaGetLatestAuditStatusResult {
// 请求
request, err := c.request(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()), map[string]interface{}{}, http.MethodPost)
// 定义
var response WxaGetLatestAuditStatusResponse
err = json.Unmarshal(request.ResponseBody, &response)

@ -1,6 +1,7 @@
package wechatopen
import (
"context"
"encoding/json"
"fmt"
"go.dtapp.net/gorequest"
@ -26,9 +27,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 (c *Client) WxaGetPage() *WxaGetPageResult {
func (c *Client) WxaGetPage(ctx context.Context) *WxaGetPageResult {
// 请求
request, err := c.request(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()), map[string]interface{}{}, http.MethodGet)
// 定义
var response WxaGetPageResponse
err = json.Unmarshal(request.ResponseBody, &response)

@ -1,6 +1,7 @@
package wechatopen
import (
"context"
"encoding/json"
"fmt"
"go.dtapp.net/gorequest"
@ -25,14 +26,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 (c *Client) WxaGetQrcode(path string) *WxaGetQrcodeResult {
func (c *Client) WxaGetQrcode(ctx context.Context, path string) *WxaGetQrcodeResult {
// 参数
params := gorequest.NewParams()
if path != "" {
params["path"] = path // 指定二维码扫码后直接进入指定页面并可同时带上参数)
}
// 请求
request, err := c.request(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()), params, http.MethodGet)
// 定义
var response WxaGetQrcodeResponse
err = json.Unmarshal(request.ResponseBody, &response)

@ -1,6 +1,7 @@
package wechatopen
import (
"context"
"encoding/json"
"fmt"
"go.dtapp.net/gorequest"
@ -35,9 +36,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 (c *Client) WxaGetTemplateDraftList() *WxaGetTemplateDraftListResult {
func (c *Client) WxaGetTemplateDraftList(ctx context.Context) *WxaGetTemplateDraftListResult {
// 请求
request, err := c.request(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()), map[string]interface{}{}, http.MethodGet)
// 定义
var response WxaGetTemplateDraftListResponse
err = json.Unmarshal(request.ResponseBody, &response)

@ -1,6 +1,7 @@
package wechatopen
import (
"context"
"encoding/json"
"fmt"
"go.dtapp.net/gorequest"
@ -36,9 +37,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 (c *Client) WxaGetTemplateList() *WxaGetTemplateListResult {
func (c *Client) WxaGetTemplateList(ctx context.Context) *WxaGetTemplateListResult {
// 请求
request, err := c.request(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()), map[string]interface{}{}, http.MethodGet)
// 定义
var response WxaGetTemplateListResponse
err = json.Unmarshal(request.ResponseBody, &response)

@ -1,6 +1,7 @@
package wechatopen
import (
"context"
"encoding/json"
"errors"
"fmt"
@ -36,13 +37,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 (c *Client) WxaGetVersionInfo() *WxaGetVersionInfoResult {
func (c *Client) WxaGetVersionInfo(ctx context.Context) *WxaGetVersionInfoResult {
accessToken := c.GetAuthorizerAccessToken()
if accessToken == "" {
return newWxaGetVersionInfoResult(WxaGetVersionInfoResponse{}, nil, gorequest.Response{}, errors.New("访问令牌为空"))
}
// 请求
request, err := c.request(fmt.Sprintf(apiUrl+"/wxa/getversioninfo?access_token=%s", accessToken), map[string]interface{}{}, http.MethodPost)
request, err := c.request(ctx, fmt.Sprintf(apiUrl+"/wxa/getversioninfo?access_token=%s", accessToken), map[string]interface{}{}, http.MethodPost)
// 定义
var response WxaGetVersionInfoResponse
err = json.Unmarshal(request.ResponseBody, &response)

@ -1,6 +1,7 @@
package wechatopen
import (
"context"
"encoding/json"
"fmt"
"go.dtapp.net/gorequest"
@ -27,11 +28,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 (c *Client) WxaGetWxaCodeUnLimit(notMustParams ...gorequest.Params) *WxaGetWxaCodeUnLimitResult {
func (c *Client) WxaGetWxaCodeUnLimit(ctx context.Context, notMustParams ...gorequest.Params) *WxaGetWxaCodeUnLimitResult {
// 参数
params := gorequest.NewParamsWith(notMustParams...)
// 请求
request, err := c.request(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()), params, http.MethodPost)
// 定义
var response WxaGetWxaCodeUnLimitResponse
err = json.Unmarshal(request.ResponseBody, &response)

@ -1,6 +1,7 @@
package wechatopen
import (
"context"
"encoding/json"
"errors"
"fmt"
@ -29,7 +30,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() *WxaMemberAuthResult {
func (c *Client) WxaMemberAuth(ctx context.Context) *WxaMemberAuthResult {
accessToken := c.GetAuthorizerAccessToken()
if accessToken == "" {
return newWxaMemberAuthResult(WxaMemberAuthResponse{}, nil, gorequest.Response{}, errors.New("访问令牌为空"))
@ -38,7 +39,7 @@ func (c *Client) WxaMemberAuth() *WxaMemberAuthResult {
params := gorequest.NewParams()
params["action"] = "get_experiencer"
// 请求
request, err := c.request(fmt.Sprintf(apiUrl+"/wxa/memberauth?access_token=%s", accessToken), params, http.MethodPost)
request, err := c.request(ctx, fmt.Sprintf(apiUrl+"/wxa/memberauth?access_token=%s", accessToken), params, http.MethodPost)
// 定义
var response WxaMemberAuthResponse
err = json.Unmarshal(request.ResponseBody, &response)

@ -1,6 +1,7 @@
package wechatopen
import (
"context"
"encoding/json"
"fmt"
"go.dtapp.net/gorequest"
@ -38,11 +39,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 (c *Client) WxaModifyDomain(notMustParams ...gorequest.Params) *WxaModifyDomainResult {
func (c *Client) WxaModifyDomain(ctx context.Context, notMustParams ...gorequest.Params) *WxaModifyDomainResult {
// 参数
params := gorequest.NewParamsWith(notMustParams...)
// 请求
request, err := c.request(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()), params, http.MethodPost)
// 定义
var response WxaModifyDomainResponse
err = json.Unmarshal(request.ResponseBody, &response)

@ -1,6 +1,7 @@
package wechatopen
import (
"context"
"encoding/json"
"fmt"
"go.dtapp.net/gorequest"
@ -25,11 +26,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 (c *Client) WxaModifyDomainDirectly(notMustParams ...gorequest.Params) *WxaModifyDomainDirectlyResult {
func (c *Client) WxaModifyDomainDirectly(ctx context.Context, notMustParams ...gorequest.Params) *WxaModifyDomainDirectlyResult {
// 参数
params := gorequest.NewParamsWith(notMustParams...)
// 请求
request, err := c.request(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()), params, http.MethodPost)
// 定义
var response WxaModifyDomainDirectlyResponse
err = json.Unmarshal(request.ResponseBody, &response)

@ -1,6 +1,7 @@
package wechatopen
import (
"context"
"encoding/json"
"fmt"
"go.dtapp.net/gorequest"
@ -25,11 +26,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 (c *Client) WxaRelease() *WxaReleaseResult {
func (c *Client) WxaRelease(ctx context.Context) *WxaReleaseResult {
// 参数
params := gorequest.NewParams()
// 请求
request, err := c.request(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()), params, http.MethodPost)
// 定义
var response WxaReleaseResponse
err = json.Unmarshal(request.ResponseBody, &response)

@ -1,6 +1,7 @@
package wechatopen
import (
"context"
"encoding/json"
"fmt"
"go.dtapp.net/gorequest"
@ -26,11 +27,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 (c *Client) WxaSecurityApplyPrivacyInterface(notMustParams ...gorequest.Params) *WxaSecurityApplyPrivacyInterfaceResult {
func (c *Client) WxaSecurityApplyPrivacyInterface(ctx context.Context, notMustParams ...gorequest.Params) *WxaSecurityApplyPrivacyInterfaceResult {
// 参数
params := gorequest.NewParamsWith(notMustParams...)
// 请求
request, err := c.request(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()), params, http.MethodPost)
// 定义
var response WxaSecurityApplyPrivacyInterfaceResponse
err = json.Unmarshal(request.ResponseBody, &response)

@ -1,6 +1,7 @@
package wechatopen
import (
"context"
"encoding/json"
"fmt"
"go.dtapp.net/gorequest"
@ -36,11 +37,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 (c *Client) WxaSecurityGetPrivacyInterface() *WxaSecurityGetPrivacyInterfaceResult {
func (c *Client) WxaSecurityGetPrivacyInterface(ctx context.Context) *WxaSecurityGetPrivacyInterfaceResult {
// 参数
params := gorequest.NewParams()
// 请求
request, err := c.request(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()), params, http.MethodGet)
// 定义
var response WxaSecurityGetPrivacyInterfaceResponse
err = json.Unmarshal(request.ResponseBody, &response)

@ -1,6 +1,7 @@
package wechatopen
import (
"context"
"encoding/json"
"fmt"
"go.dtapp.net/gorequest"
@ -26,11 +27,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 (c *Client) WxaSubmitAudit(notMustParams ...gorequest.Params) *WxaSubmitAuditResult {
func (c *Client) WxaSubmitAudit(ctx context.Context, notMustParams ...gorequest.Params) *WxaSubmitAuditResult {
// 参数
params := gorequest.NewParamsWith(notMustParams...)
// 请求
request, err := c.request(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()), params, http.MethodPost)
// 定义
var response WxaSubmitAuditResponse
err = json.Unmarshal(request.ResponseBody, &response)

@ -1,6 +1,7 @@
package wechatopen
import (
"context"
"encoding/json"
"fmt"
"go.dtapp.net/gorequest"
@ -25,7 +26,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 (c *Client) WxaUnbindTester(wechatid, userstr string) *WxaUnbindTesterResult {
func (c *Client) WxaUnbindTester(ctx context.Context, wechatid, userstr string) *WxaUnbindTesterResult {
// 参数
params := gorequest.NewParams()
if wechatid != "" {
@ -33,7 +34,7 @@ func (c *Client) WxaUnbindTester(wechatid, userstr string) *WxaUnbindTesterResul
}
params["userstr"] = userstr
// 请求
request, err := c.request(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()), params, http.MethodPost)
// 定义
var response WxaUnbindTesterResponse
err = json.Unmarshal(request.ResponseBody, &response)

Loading…
Cancel
Save