|
|
@@ -3,24 +3,36 @@ package com.mrxu.framework.common.weixin.api;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.mrxu.framework.common.weixin.base.WxHttp;
|
|
|
import com.mrxu.framework.common.weixin.bean.AuthorizationInfo;
|
|
|
+import com.mrxu.framework.common.weixin.bean.AuthorizerToken;
|
|
|
import com.mrxu.framework.common.weixin.bean.ComponentToken;
|
|
|
import com.mrxu.framework.common.weixin.bean.Preauthcode;
|
|
|
|
|
|
public class ComponentTokenApi {
|
|
|
|
|
|
- private static String token = "https://api.weixin.qq.com/cgi-bin/component/api_component_token";
|
|
|
-
|
|
|
- private static String createPreauthcode = "https://api.weixin.qq.com/cgi-bin/component/api_create_preauthcode?component_access_token=";
|
|
|
-
|
|
|
+ private static String component_token = "https://api.weixin.qq.com/cgi-bin/component/api_component_token";
|
|
|
+ private static String authorizer_token = "https://api.weixin.qq.com/cgi-bin/component/api_authorizer_token?component_access_token=";
|
|
|
+ private static String create_preauthcode = "https://api.weixin.qq.com/cgi-bin/component/api_create_preauthcode?component_access_token=";
|
|
|
private static String query_auth = "https://api.weixin.qq.com/cgi-bin/component/api_query_auth?component_access_token=";
|
|
|
|
|
|
// https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/ThirdParty/token/component_access_token.html
|
|
|
- public static ComponentToken getToken(String componentAppid, String componentAppsecret,String componentVerifyTicket) {
|
|
|
+ public static ComponentToken getComponentToken(String componentAppid, String componentAppsecret,String componentVerifyTicket) {
|
|
|
JSONObject json = new JSONObject();
|
|
|
json.put("component_appid", componentAppid);
|
|
|
json.put("component_appsecret", componentAppsecret);
|
|
|
json.put("component_verify_ticket", componentVerifyTicket);
|
|
|
- ComponentToken rs = WxHttp.post(ComponentToken.class,token,json);
|
|
|
+ ComponentToken rs = WxHttp.post(ComponentToken.class,component_token,json);
|
|
|
+ return rs;
|
|
|
+ }
|
|
|
+
|
|
|
+ // https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/ThirdParty/token/api_authorizer_token.html
|
|
|
+ // 获取/刷新 小程序、公众号 接口调用令牌
|
|
|
+ public static AuthorizerToken getAuthorizerToken(String componentAppid, String componentAccessToken,
|
|
|
+ String authorizerAppid, String authorizerRefreshToken) {
|
|
|
+ JSONObject json = new JSONObject();
|
|
|
+ json.put("component_appid", componentAppid);
|
|
|
+ json.put("authorizer_appid", authorizerAppid);
|
|
|
+ json.put("authorizer_refresh_token", authorizerRefreshToken);
|
|
|
+ AuthorizerToken rs = WxHttp.post(AuthorizerToken.class,authorizer_token+componentAccessToken,json);
|
|
|
return rs;
|
|
|
}
|
|
|
|
|
|
@@ -31,7 +43,7 @@ public class ComponentTokenApi {
|
|
|
public static Preauthcode createPreauthcode(String componentAppid, String componentAccessToken) {
|
|
|
JSONObject json = new JSONObject();
|
|
|
json.put("component_appid", componentAppid);
|
|
|
- Preauthcode rs = WxHttp.post(Preauthcode.class,createPreauthcode+componentAccessToken,json);
|
|
|
+ Preauthcode rs = WxHttp.post(Preauthcode.class,create_preauthcode+componentAccessToken,json);
|
|
|
return rs;
|
|
|
}
|
|
|
|
|
|
@@ -43,7 +55,7 @@ public class ComponentTokenApi {
|
|
|
JSONObject json = new JSONObject();
|
|
|
json.put("component_appid", componentAppid);
|
|
|
json.put("authorization_code", authorizationCode);
|
|
|
- AuthorizationInfo rs = WxHttp.post(AuthorizationInfo.class,createPreauthcode+componentAccessToken,json);
|
|
|
+ AuthorizationInfo rs = WxHttp.post(AuthorizationInfo.class,query_auth+componentAccessToken,json);
|
|
|
return rs;
|
|
|
}
|
|
|
|