From 52fb5596d3bd98054ee40c000dfd18d950ceb76b Mon Sep 17 00:00:00 2001 From: LarryLiu Date: Mon, 31 Mar 2025 10:51:46 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=9C=80=E6=96=B0=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E7=9A=84=E6=8E=88=E6=9D=83=E5=9C=B0=E5=9D=80=20(#823)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Update accessToken.go add openplatform refresh_token * Update accessToken.go openplatform add refresh_token expire set 10 year * Update openplatform/context/accessToken.go Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update accessToken.go 修改最新的授权H5链接地址 * Update accessToken.go 增加新版本授权链接 * Update accessToken.go 增加新版本授权链接 --------- Co-authored-by: houseme Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- openplatform/context/accessToken.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/openplatform/context/accessToken.go b/openplatform/context/accessToken.go index 9a231be..41dc619 100644 --- a/openplatform/context/accessToken.go +++ b/openplatform/context/accessToken.go @@ -20,6 +20,7 @@ const ( getComponentInfoURL = "https://api.weixin.qq.com/cgi-bin/component/api_get_authorizer_info?component_access_token=%s" componentLoginURL = "https://mp.weixin.qq.com/cgi-bin/componentloginpage?component_appid=%s&pre_auth_code=%s&redirect_uri=%s&auth_type=%d&biz_appid=%s" bindComponentURL = "https://mp.weixin.qq.com/safe/bindcomponent?action=bindcomponent&auth_type=%d&no_scan=1&component_appid=%s&pre_auth_code=%s&redirect_uri=%s&biz_appid=%s#wechat_redirect" + bindComponentURLV2 = "https://open.weixin.qq.com/wxaopen/safe/bindcomponent?action=bindcomponent&auth_type=%d&no_scan=1&component_appid=%s&pre_auth_code=%s&redirect_uri=%s&biz_appid=%s#wechat_redirect" // TODO 获取授权方选项信息 // getComponentConfigURL = "https://api.weixin.qq.com/cgi-bin/component/api_get_authorizer_option?component_access_token=%s" // TODO 获取已授权的账号信息 @@ -137,6 +138,20 @@ func (ctx *Context) GetBindComponentURL(redirectURI string, authType int, bizApp return ctx.GetBindComponentURLContext(context.Background(), redirectURI, authType, bizAppID) } +// GetBindComponentURLV2Context 获取新版本第三方公众号授权链接(链接跳转,适用移动端) +func (ctx *Context) GetBindComponentURLV2Context(stdCtx context.Context, redirectURI string, authType int, bizAppID string) (string, error) { + code, err := ctx.GetPreCodeContext(stdCtx) + if err != nil { + return "", err + } + return fmt.Sprintf(bindComponentURLV2, authType, ctx.AppID, code, url.QueryEscape(redirectURI), bizAppID), nil +} + +// GetBindComponentURLV2 获取新版本第三方公众号授权链接(链接跳转,适用移动端) +func (ctx *Context) GetBindComponentURLV2(redirectURI string, authType int, bizAppID string) (string, error) { + return ctx.GetBindComponentURLContext(context.Background(), redirectURI, authType, bizAppID) +} + // ID 微信返回接口中各种类型字段 type ID struct { ID int `json:"id"`