|
|
@@ -31,9 +31,10 @@ func NewWxApiService(masterId, componentAppid, componentAppsecret string) (wxApi |
|
|
|
} |
|
|
|
cacheKey := fmt.Sprintf(md.MasterComponentVerifyTicket, wxApiService.MasterId) |
|
|
|
cacheComponentVerifyTicket, _ := cache.GetString(cacheKey) |
|
|
|
if cacheComponentVerifyTicket != "" { |
|
|
|
if cacheComponentVerifyTicket == "" { |
|
|
|
return wxApiService, errors.New("微信验证票据ticket未获取到") |
|
|
|
} |
|
|
|
wxApiService.ComponentVerifyTicket = cacheComponentVerifyTicket |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
@@ -41,14 +42,14 @@ func NewWxApiService(masterId, componentAppid, componentAppsecret string) (wxApi |
|
|
|
func (wxApiService *WxApiService) GetComponentAccessToken() (cacheComponentAccessToken string, err error) { // set方法 |
|
|
|
cacheKey := fmt.Sprintf(md.MasterComponentAccessToken, wxApiService.MasterId) |
|
|
|
cacheComponentAccessToken, _ = cache.GetString(cacheKey) |
|
|
|
if cacheComponentAccessToken != "" { |
|
|
|
if cacheComponentAccessToken == "" { |
|
|
|
url := "https://api.weixin.qq.com/cgi-bin/component/api_component_token" |
|
|
|
params := map[string]string{ |
|
|
|
"component_appid": wxApiService.ComponentAppid, |
|
|
|
"component_appsecret": wxApiService.ComponentAppsecret, |
|
|
|
"component_verify_ticket": wxApiService.ComponentVerifyTicket, |
|
|
|
} |
|
|
|
postBody, err1 := utils.CurlPost(url, params, nil) |
|
|
|
postBody, err1 := utils.CurlPost(url, utils.SerializeStr(params), nil) |
|
|
|
if err1 != nil { |
|
|
|
return cacheComponentAccessToken, err1 |
|
|
|
} |
|
|
@@ -91,7 +92,7 @@ func (wxApiService *WxApiService) GetPreAuthCode() (preAuthCode string, err erro |
|
|
|
params := map[string]string{ |
|
|
|
"component_appid": wxApiService.ComponentAppid, |
|
|
|
} |
|
|
|
postBody, err := utils.CurlPost(url, params, nil) |
|
|
|
postBody, err := utils.CurlPost(url, utils.SerializeStr(params), nil) |
|
|
|
if err != nil { |
|
|
|
return |
|
|
|
} |
|
|
|