mirror of
				https://gitee.com/binary/weixin-java-tools.git
				synced 2025-11-01 03:25:35 +08:00 
			
		
		
		
	🎨 #3270【开放平台】修改获取授权方选项信息、设置授权方选项信息接口的地址
This commit is contained in:
		| @ -55,13 +55,13 @@ public interface WxOpenComponentService { | ||||
|    */ | ||||
|   String API_GET_AUTHORIZER_INFO_URL = "https://api.weixin.qq.com/cgi-bin/component/api_get_authorizer_info"; | ||||
|   /** | ||||
|    * The constant API_GET_AUTHORIZER_OPTION_URL. | ||||
|    * The constant GET_AUTHORIZER_OPTION_URL. | ||||
|    */ | ||||
|   String API_GET_AUTHORIZER_OPTION_URL = "https://api.weixin.qq.com/cgi-bin/component/api_get_authorizer_option"; | ||||
|   String GET_AUTHORIZER_OPTION_URL = "https://api.weixin.qq.com/cgi-bin/component/get_authorizer_option"; | ||||
|   /** | ||||
|    * The constant API_SET_AUTHORIZER_OPTION_URL. | ||||
|    * The constant SET_AUTHORIZER_OPTION_URL. | ||||
|    */ | ||||
|   String API_SET_AUTHORIZER_OPTION_URL = "https://api.weixin.qq.com/cgi-bin/component/api_set_authorizer_option"; | ||||
|   String SET_AUTHORIZER_OPTION_URL = "https://api.weixin.qq.com/cgi-bin/component/set_authorizer_option"; | ||||
|   /** | ||||
|    * The constant API_GET_AUTHORIZER_LIST. | ||||
|    */ | ||||
| @ -202,6 +202,7 @@ public interface WxOpenComponentService { | ||||
|   String BATCH_SHARE_ENV = "https://api.weixin.qq.com/componenttcb/batchshareenv"; | ||||
|  | ||||
|   String COMPONENT_CLEAR_QUOTA_URL = "https://api.weixin.qq.com/cgi-bin/component/clear_quota/v2"; | ||||
|  | ||||
|   /** | ||||
|    * Gets wx mp service by appid. | ||||
|    * | ||||
| @ -291,6 +292,8 @@ public interface WxOpenComponentService { | ||||
|    */ | ||||
|   String post(String uri, String postData, String accessTokenKey) throws WxErrorException; | ||||
|  | ||||
|   String post(String uri, String postData, String accessTokenKey, String accessToken) throws WxErrorException; | ||||
|  | ||||
|   /** | ||||
|    * Get string. | ||||
|    * | ||||
| @ -1092,7 +1095,7 @@ public interface WxOpenComponentService { | ||||
|    * 使用 AppSecret 重置第三方平台 API 调用次数 | ||||
|    * https://developers.weixin.qq.com/doc/oplatform/openApi/OpenApiDoc/openapi/clearComponentQuotaByAppSecret.html | ||||
|    * | ||||
|    * @param appid  授权用户appid | ||||
|    * @param appid 授权用户appid | ||||
|    * @return | ||||
|    * @throws WxErrorException | ||||
|    */ | ||||
|  | ||||
| @ -231,6 +231,20 @@ public class WxOpenComponentServiceImpl implements WxOpenComponentService { | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   @Override | ||||
|   public String post(String uri, String postData, String accessTokenKey, String accessToken) throws WxErrorException { | ||||
|     String uriWithComponentAccessToken = uri + (uri.contains("?") ? "&" : "?") + accessTokenKey + "=" + accessToken; | ||||
|     try { | ||||
|       return getWxOpenService().post(uriWithComponentAccessToken, postData); | ||||
|     } catch (WxErrorException e) { | ||||
|       WxError error = e.getError(); | ||||
|       if (error.getErrorCode() != 0) { | ||||
|         throw new WxErrorException(error, e); | ||||
|       } | ||||
|       return error.getErrorMsg(); | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   @Override | ||||
|   public String get(String uri) throws WxErrorException { | ||||
|     return get(uri, "component_access_token"); | ||||
| @ -398,22 +412,24 @@ public class WxOpenComponentServiceImpl implements WxOpenComponentService { | ||||
|  | ||||
|   @Override | ||||
|   public WxOpenAuthorizerOptionResult getAuthorizerOption(String authorizerAppid, String optionName) throws WxErrorException { | ||||
|     String authorizerAccessToken = this.getAuthorizerAccessToken(authorizerAppid, false); | ||||
|     JsonObject jsonObject = new JsonObject(); | ||||
|     jsonObject.addProperty("component_appid", getWxOpenConfigStorage().getComponentAppId()); | ||||
|     jsonObject.addProperty("authorizer_appid", authorizerAppid); | ||||
|     jsonObject.addProperty("option_name", optionName); | ||||
|     String responseContent = post(API_GET_AUTHORIZER_OPTION_URL, jsonObject.toString()); | ||||
|     String responseContent = post(GET_AUTHORIZER_OPTION_URL, jsonObject.toString(), "access_token", authorizerAccessToken); | ||||
|     return WxOpenGsonBuilder.create().fromJson(responseContent, WxOpenAuthorizerOptionResult.class); | ||||
|   } | ||||
|  | ||||
|   @Override | ||||
|   public void setAuthorizerOption(String authorizerAppid, String optionName, String optionValue) throws WxErrorException { | ||||
|     String authorizerAccessToken = this.getAuthorizerAccessToken(authorizerAppid, false); | ||||
|     JsonObject jsonObject = new JsonObject(); | ||||
|     jsonObject.addProperty("component_appid", getWxOpenConfigStorage().getComponentAppId()); | ||||
|     jsonObject.addProperty("authorizer_appid", authorizerAppid); | ||||
|     jsonObject.addProperty("option_name", optionName); | ||||
|     jsonObject.addProperty("option_value", optionValue); | ||||
|     post(API_SET_AUTHORIZER_OPTION_URL, jsonObject.toString()); | ||||
|     post(SET_AUTHORIZER_OPTION_URL, jsonObject.toString(), "access_token", authorizerAccessToken); | ||||
|   } | ||||
|  | ||||
|   @Override | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 waitxy
					waitxy