|
|
@@ -3,11 +3,14 @@ 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.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=";
|
|
|
+
|
|
|
// 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) {
|
|
|
JSONObject json = new JSONObject();
|
|
|
@@ -18,4 +21,15 @@ public class ComponentTokenApi {
|
|
|
return rs;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 预授权码(pre_auth_code)是第三方平台方实现授权托管的必备信息,每个预授权码有效期为 1800秒。
|
|
|
+ * 需要先获取令牌才能调用。使用过程中如遇到问题,可在开放平台服务商专区发帖交流。
|
|
|
+ */
|
|
|
+ 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);
|
|
|
+ return rs;
|
|
|
+ }
|
|
|
+
|
|
|
}
|