From c1481b9a79d9b26361ca3d9bfcbfd7f76f654980 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=85=89=E6=98=A5?= Date: Mon, 3 Jan 2022 10:38:05 +0800 Subject: [PATCH] update wechatminiprogram --- .../wechatminiprogram/wxa.query_urllink.go | 56 +++++++++++++++++++ service/wechatminiprogram/wxa.queryscheme.go | 20 +++++++ 2 files changed, 76 insertions(+) create mode 100644 service/wechatminiprogram/wxa.query_urllink.go create mode 100644 service/wechatminiprogram/wxa.queryscheme.go diff --git a/service/wechatminiprogram/wxa.query_urllink.go b/service/wechatminiprogram/wxa.query_urllink.go new file mode 100644 index 00000000..2ad4c373 --- /dev/null +++ b/service/wechatminiprogram/wxa.query_urllink.go @@ -0,0 +1,56 @@ +package wechatminiprogram + +import ( + "encoding/json" + "fmt" + "net/http" +) + +type WxaQueryUrlLinkResponse struct { + Errcode int `json:"errcode"` + Errmsg string `json:"errmsg"` + UrlLinkInfo struct { + Appid string `json:"appid"` + Path string `json:"path"` + Query string `json:"query"` + CreateTime int `json:"create_time"` + ExpireTime int `json:"expire_time"` + EnvVersion string `json:"env_version"` + CloudBase struct { + Env string `json:"env"` + Doamin string `json:"doamin"` + Path string `json:"path"` + Query string `json:"query"` + ResourceAppid string `json:"resource_appid"` + } `json:"cloud_base"` + } `json:"url_link_info"` + UrlLinkQuota struct { + LongTimeUsed int `json:"long_time_used"` + LongTimeLimit int `json:"long_time_limit"` + } `json:"url_link_quota"` +} + +type WxaQueryUrlLinkResult struct { + Result WxaQueryUrlLinkResponse // 结果 + Body []byte // 内容 + Err error // 错误 +} + +func NewWxaQueryUrlLinkResult(result WxaQueryUrlLinkResponse, body []byte, err error) *WxaQueryUrlLinkResult { + return &WxaQueryUrlLinkResult{Result: result, Body: body, Err: err} +} + +// WxaQueryUrlLink 查询小程序 url_link 配置,及长期有效 quota +// https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/url-link/urllink.query.html +func (app *App) WxaQueryUrlLink(urlLink string) *WxaQueryUrlLinkResult { + // 参数 + param := NewParams() + param.Set("url_link", urlLink) + params := app.NewParamsWith(param) + // 请求 + body, err := app.request(fmt.Sprintf("https://api.weixin.qq.com/wxa/query_urllink?access_token=%s", app.AccessToken), params, http.MethodPost) + // 定义 + var response WxaQueryUrlLinkResponse + err = json.Unmarshal(body, &response) + return NewWxaQueryUrlLinkResult(response, body, err) +} diff --git a/service/wechatminiprogram/wxa.queryscheme.go b/service/wechatminiprogram/wxa.queryscheme.go new file mode 100644 index 00000000..c8614300 --- /dev/null +++ b/service/wechatminiprogram/wxa.queryscheme.go @@ -0,0 +1,20 @@ +package wechatminiprogram + +import ( + "encoding/json" + "fmt" + "net/http" +) + +// WxaQueryScheme 查询小程序 scheme 码,及长期有效 quota +// https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/url-scheme/urlscheme.query.html +func (app *App) WxaQueryScheme(notMustParams ...Params) *BusinessGetLiveInfoResult { + // 参数 + params := app.NewParamsWith(notMustParams...) + // 请求 + body, err := app.request(fmt.Sprintf("https://api.weixin.qq.com/wxa/queryscheme?access_token=%s", app.AccessToken), params, http.MethodPost) + // 定义 + var response BusinessGetLiveInfoResponse + err = json.Unmarshal(body, &response) + return NewBusinessGetLiveInfoResult(response, body, err) +}