Token优化
This commit is contained in:
parent
8902d8aef7
commit
fa6b60af82
@ -0,0 +1,36 @@
|
||||
package com.foxinmy.weixin4j.token;
|
||||
|
||||
import com.foxinmy.weixin4j.http.weixin.WeixinRequestExecutor;
|
||||
|
||||
/**
|
||||
*
|
||||
* @className: AbstractTokenCreator
|
||||
* @author jinyu
|
||||
* @date 2016年4月21日
|
||||
* @since JDK 1.6
|
||||
* @see
|
||||
*/
|
||||
public abstract class AbstractTokenCreator implements TokenCreator {
|
||||
|
||||
protected final WeixinRequestExecutor weixinExecutor;
|
||||
|
||||
public AbstractTokenCreator() {
|
||||
this.weixinExecutor = new WeixinRequestExecutor();
|
||||
}
|
||||
|
||||
/**
|
||||
* 缓存key:附加weixin4j前缀
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getCacheKey() {
|
||||
return String.format("weixin4j_%s", getCacheKey0());
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回缓存KEY的名称:建议接口类型命名 如 mp_token_{appid}
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public abstract String getCacheKey0();
|
||||
}
|
||||
@ -29,17 +29,14 @@ public class FileTokenStorager implements TokenStorager {
|
||||
|
||||
@Override
|
||||
public Token lookup(String cacheKey) throws WeixinException {
|
||||
File token_file = new File(String.format("%s/%s.xml", cachePath,
|
||||
cacheKey));
|
||||
File token_file = new File(String.format("%s/%s.xml", cachePath, cacheKey));
|
||||
try {
|
||||
if (token_file.exists()) {
|
||||
Token token = XmlStream.fromXML(
|
||||
new FileInputStream(token_file), Token.class);
|
||||
Token token = XmlStream.fromXML(new FileInputStream(token_file), Token.class);
|
||||
if (token.getCreateTime() < 0) {
|
||||
return token;
|
||||
}
|
||||
if ((token.getCreateTime() + (token.getExpiresIn() * 1000l) - CUTMS) > System
|
||||
.currentTimeMillis()) {
|
||||
if ((token.getCreateTime() + (token.getExpiresIn() * 1000l) - CUTMS) > System.currentTimeMillis()) {
|
||||
return token;
|
||||
}
|
||||
}
|
||||
@ -52,10 +49,7 @@ public class FileTokenStorager implements TokenStorager {
|
||||
@Override
|
||||
public void caching(String cacheKey, Token token) throws WeixinException {
|
||||
try {
|
||||
XmlStream.toXML(
|
||||
token,
|
||||
new FileOutputStream(new File(String.format("%s/%s.xml",
|
||||
cachePath, cacheKey))));
|
||||
XmlStream.toXML(token, new FileOutputStream(new File(String.format("%s/%s.xml", cachePath, cacheKey))));
|
||||
} catch (IOException e) {
|
||||
throw new WeixinException(e);
|
||||
}
|
||||
@ -64,12 +58,10 @@ public class FileTokenStorager implements TokenStorager {
|
||||
@Override
|
||||
public Token evict(String cacheKey) throws WeixinException {
|
||||
Token token = null;
|
||||
File token_file = new File(String.format("%s/%s.xml", cachePath,
|
||||
cacheKey));
|
||||
File token_file = new File(String.format("%s/%s.xml", cachePath, cacheKey));
|
||||
try {
|
||||
if (token_file.exists()) {
|
||||
token = XmlStream.fromXML(new FileInputStream(token_file),
|
||||
Token.class);
|
||||
token = XmlStream.fromXML(new FileInputStream(token_file), Token.class);
|
||||
token_file.delete();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
@ -83,9 +75,8 @@ public class FileTokenStorager implements TokenStorager {
|
||||
File[] files = new File(cachePath).listFiles(new FileFilter() {
|
||||
@Override
|
||||
public boolean accept(File file) {
|
||||
return file.isFile()
|
||||
&& "xml".equals(FileUtil.getFileExtension(file
|
||||
.getName()));
|
||||
return file.isFile() && file.getName().startsWith(PREFIX)
|
||||
&& "xml".equals(FileUtil.getFileExtension(file.getName()));
|
||||
}
|
||||
});
|
||||
for (File token : files) {
|
||||
|
||||
@ -45,8 +45,7 @@ public class RedisTokenStorager implements TokenStorager {
|
||||
this.jedisPool = new JedisPool(jedisPoolConfig, host, port);
|
||||
}
|
||||
|
||||
public RedisTokenStorager(String host, int port,
|
||||
JedisPoolConfig jedisPoolConfig) {
|
||||
public RedisTokenStorager(String host, int port, JedisPoolConfig jedisPoolConfig) {
|
||||
this(new JedisPool(jedisPoolConfig, host, port));
|
||||
}
|
||||
|
||||
@ -78,8 +77,7 @@ public class RedisTokenStorager implements TokenStorager {
|
||||
jedis = jedisPool.getResource();
|
||||
jedis.hmset(cacheKey, token2map(token));
|
||||
if (token.getExpiresIn() > 0) {
|
||||
jedis.expire(cacheKey, token.getExpiresIn()
|
||||
- (int) (CUTMS / 1000l));
|
||||
jedis.expire(cacheKey, token.getExpiresIn() - (int) (CUTMS / 1000l));
|
||||
}
|
||||
} finally {
|
||||
if (jedis != null) {
|
||||
@ -130,7 +128,7 @@ public class RedisTokenStorager implements TokenStorager {
|
||||
Jedis jedis = null;
|
||||
try {
|
||||
jedis = jedisPool.getResource();
|
||||
Set<String> cacheKeys = jedis.keys("weixin4j_*");
|
||||
Set<String> cacheKeys = jedis.keys(String.format("%s*", PREFIX));
|
||||
if (!cacheKeys.isEmpty()) {
|
||||
Pipeline pipeline = jedis.pipelined();
|
||||
for (String cacheKey : cacheKeys) {
|
||||
|
||||
@ -1,30 +1,30 @@
|
||||
package com.foxinmy.weixin4j.token;
|
||||
|
||||
import com.foxinmy.weixin4j.exception.WeixinException;
|
||||
import com.foxinmy.weixin4j.model.Token;
|
||||
|
||||
/**
|
||||
* TOKEN创建者
|
||||
*
|
||||
* @className TokenCreator
|
||||
* @author jy
|
||||
* @date 2015年1月10日
|
||||
* @since JDK 1.6
|
||||
* @see
|
||||
*/
|
||||
public interface TokenCreator {
|
||||
/**
|
||||
* 返回缓存KEY的名称
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getCacheKey();
|
||||
|
||||
/**
|
||||
* 创建token
|
||||
*
|
||||
* @return
|
||||
* @throws WeixinException
|
||||
*/
|
||||
public Token createToken() throws WeixinException;
|
||||
}
|
||||
package com.foxinmy.weixin4j.token;
|
||||
|
||||
import com.foxinmy.weixin4j.exception.WeixinException;
|
||||
import com.foxinmy.weixin4j.model.Token;
|
||||
|
||||
/**
|
||||
* TOKEN创建者
|
||||
*
|
||||
* @className TokenCreator
|
||||
* @author jy
|
||||
* @date 2015年1月10日
|
||||
* @since JDK 1.6
|
||||
* @see
|
||||
*/
|
||||
public interface TokenCreator {
|
||||
/**
|
||||
* 返回缓存KEY的名称
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getCacheKey();
|
||||
|
||||
/**
|
||||
* 创建token
|
||||
*
|
||||
* @return
|
||||
* @throws WeixinException
|
||||
*/
|
||||
public Token createToken() throws WeixinException;
|
||||
}
|
||||
|
||||
@ -19,4 +19,8 @@ public interface TokenStorager extends CacheStorager<Token> {
|
||||
* 考虑到程序的临界值,实际有效时间应该减去下面这个数
|
||||
*/
|
||||
final long CUTMS = 1 * 60 * 1000l;
|
||||
/**
|
||||
* 缓存key的前缀
|
||||
*/
|
||||
final String PREFIX = "weixin4j_";
|
||||
}
|
||||
|
||||
@ -1,10 +1,6 @@
|
||||
package com.foximy.weixin4j.example.server;
|
||||
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
|
||||
import com.foxinmy.weixin4j.exception.WeixinException;
|
||||
import com.foxinmy.weixin4j.spring.SpringBeanFactory;
|
||||
import com.foxinmy.weixin4j.startup.WeixinServerBootstrap;
|
||||
|
||||
/**
|
||||
@ -42,11 +38,11 @@ public class Weixin4jServerStartupWithoutThread {
|
||||
* @throws WeixinException
|
||||
*/
|
||||
public static void main(String[] args) throws WeixinException {
|
||||
ApplicationContext applicationContext = new ClassPathXmlApplicationContext(
|
||||
new String[] { "classpath:/spring-bean.xml" });
|
||||
//ApplicationContext applicationContext = new ClassPathXmlApplicationContext(
|
||||
// new String[] { "classpath:/spring-bean.xml" });
|
||||
new WeixinServerBootstrap(aesToken)
|
||||
.handlerPackagesToScan(handlerPackage).openAlwaysResponse()
|
||||
.resolveBeanFactory(new SpringBeanFactory(applicationContext))
|
||||
//.resolveBeanFactory(new SpringBeanFactory(applicationContext))
|
||||
.startup(port);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,63 +1,60 @@
|
||||
package com.foxinmy.weixin4j.mp.token;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.foxinmy.weixin4j.exception.WeixinException;
|
||||
import com.foxinmy.weixin4j.http.weixin.WeixinRequestExecutor;
|
||||
import com.foxinmy.weixin4j.http.weixin.WeixinResponse;
|
||||
import com.foxinmy.weixin4j.model.Token;
|
||||
import com.foxinmy.weixin4j.mp.type.URLConsts;
|
||||
import com.foxinmy.weixin4j.token.TokenCreator;
|
||||
import com.foxinmy.weixin4j.token.TokenHolder;
|
||||
import com.foxinmy.weixin4j.type.TicketType;
|
||||
|
||||
/**
|
||||
* 微信公众平台TICKET创建(包括jsticket、其它JSSDK所需的ticket的创建
|
||||
*
|
||||
* @className WeixinJSTicketCreator
|
||||
* @author jy
|
||||
* @date 2015年1月10日
|
||||
* @since JDK 1.6
|
||||
* @see <a href=
|
||||
* "https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421141115&token=&lang=zh_CN">
|
||||
* JS TICKET</a>
|
||||
*/
|
||||
public class WeixinTicketCreator implements TokenCreator {
|
||||
|
||||
private final String appid;
|
||||
private final TicketType ticketType;
|
||||
private final TokenHolder weixinTokenHolder;
|
||||
private final WeixinRequestExecutor weixinExecutor;
|
||||
|
||||
/**
|
||||
* jssdk
|
||||
*
|
||||
* @param appid
|
||||
* 公众号的appid
|
||||
* @param ticketType
|
||||
* 票据类型
|
||||
* @param weixinTokenHolder
|
||||
* <font color="red">公众平台的access_token</font>
|
||||
*/
|
||||
public WeixinTicketCreator(String appid, TicketType ticketType, TokenHolder weixinTokenHolder) {
|
||||
this.appid = appid;
|
||||
this.ticketType = ticketType;
|
||||
this.weixinTokenHolder = weixinTokenHolder;
|
||||
this.weixinExecutor = new WeixinRequestExecutor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCacheKey() {
|
||||
return String.format("weixin4j_mp_ticket_%s_%s", ticketType.name(), appid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Token createToken() throws WeixinException {
|
||||
WeixinResponse response = weixinExecutor.get(
|
||||
String.format(URLConsts.TICKET_URL, weixinTokenHolder.getToken().getAccessToken(), ticketType.name()));
|
||||
JSONObject result = response.getAsJson();
|
||||
Token token = new Token(result.getString("ticket"));
|
||||
token.setExpiresIn(result.getIntValue("expires_in"));
|
||||
token.setOriginalResult(response.getAsString());
|
||||
return token;
|
||||
}
|
||||
}
|
||||
package com.foxinmy.weixin4j.mp.token;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.foxinmy.weixin4j.exception.WeixinException;
|
||||
import com.foxinmy.weixin4j.http.weixin.WeixinResponse;
|
||||
import com.foxinmy.weixin4j.model.Token;
|
||||
import com.foxinmy.weixin4j.mp.type.URLConsts;
|
||||
import com.foxinmy.weixin4j.token.AbstractTokenCreator;
|
||||
import com.foxinmy.weixin4j.token.TokenHolder;
|
||||
import com.foxinmy.weixin4j.type.TicketType;
|
||||
|
||||
/**
|
||||
* 微信公众平台TICKET创建(包括jsticket、其它JSSDK所需的ticket的创建
|
||||
*
|
||||
* @className WeixinJSTicketCreator
|
||||
* @author jy
|
||||
* @date 2015年1月10日
|
||||
* @since JDK 1.6
|
||||
* @see <a href=
|
||||
* "https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421141115&token=&lang=zh_CN">
|
||||
* JS TICKET</a>
|
||||
*/
|
||||
public class WeixinTicketCreator extends AbstractTokenCreator {
|
||||
|
||||
private final String appid;
|
||||
private final TicketType ticketType;
|
||||
private final TokenHolder weixinTokenHolder;
|
||||
|
||||
/**
|
||||
* jssdk
|
||||
*
|
||||
* @param appid
|
||||
* 公众号的appid
|
||||
* @param ticketType
|
||||
* 票据类型
|
||||
* @param weixinTokenHolder
|
||||
* <font color="red">公众平台的access_token</font>
|
||||
*/
|
||||
public WeixinTicketCreator(String appid, TicketType ticketType, TokenHolder weixinTokenHolder) {
|
||||
this.appid = appid;
|
||||
this.ticketType = ticketType;
|
||||
this.weixinTokenHolder = weixinTokenHolder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCacheKey0() {
|
||||
return String.format("mp_ticket_%s_%s", ticketType.name(), appid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Token createToken() throws WeixinException {
|
||||
WeixinResponse response = weixinExecutor.get(
|
||||
String.format(URLConsts.TICKET_URL, weixinTokenHolder.getToken().getAccessToken(), ticketType.name()));
|
||||
JSONObject result = response.getAsJson();
|
||||
Token token = new Token(result.getString("ticket"));
|
||||
token.setExpiresIn(result.getIntValue("expires_in"));
|
||||
token.setOriginalResult(response.getAsString());
|
||||
return token;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,56 +1,56 @@
|
||||
package com.foxinmy.weixin4j.mp.token;
|
||||
|
||||
import com.alibaba.fastjson.TypeReference;
|
||||
import com.foxinmy.weixin4j.exception.WeixinException;
|
||||
import com.foxinmy.weixin4j.http.weixin.WeixinRequestExecutor;
|
||||
import com.foxinmy.weixin4j.http.weixin.WeixinResponse;
|
||||
import com.foxinmy.weixin4j.model.Token;
|
||||
import com.foxinmy.weixin4j.mp.type.URLConsts;
|
||||
import com.foxinmy.weixin4j.token.TokenCreator;
|
||||
|
||||
/**
|
||||
* 微信公众平台TOKEN创建者
|
||||
*
|
||||
* @className WeixinTokenCreator
|
||||
* @author jy
|
||||
* @date 2015年1月10日
|
||||
* @since JDK 1.6
|
||||
* @see <a
|
||||
* href="https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140183&token=&lang=zh_CN">微信公众平台获取token说明</a>
|
||||
* @see com.foxinmy.weixin4j.model.Token
|
||||
*/
|
||||
public class WeixinTokenCreator implements TokenCreator {
|
||||
|
||||
private final WeixinRequestExecutor weixinExecutor;
|
||||
private final String appid;
|
||||
private final String secret;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param appid
|
||||
* 公众号ID
|
||||
* @param secret
|
||||
* 公众号secret
|
||||
*/
|
||||
public WeixinTokenCreator(String appid, String secret) {
|
||||
this.appid = appid;
|
||||
this.secret = secret;
|
||||
this.weixinExecutor = new WeixinRequestExecutor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCacheKey() {
|
||||
return String.format("weixin4j_mp_token_%s", appid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Token createToken() throws WeixinException {
|
||||
String tokenUrl = String.format(URLConsts.ASSESS_TOKEN_URL, appid,
|
||||
secret);
|
||||
WeixinResponse response = weixinExecutor.get(tokenUrl);
|
||||
Token token = response.getAsObject(new TypeReference<Token>() {
|
||||
});
|
||||
token.setOriginalResult(response.getAsString());
|
||||
return token;
|
||||
}
|
||||
}
|
||||
package com.foxinmy.weixin4j.mp.token;
|
||||
|
||||
import com.alibaba.fastjson.TypeReference;
|
||||
import com.foxinmy.weixin4j.exception.WeixinException;
|
||||
import com.foxinmy.weixin4j.http.weixin.WeixinRequestExecutor;
|
||||
import com.foxinmy.weixin4j.http.weixin.WeixinResponse;
|
||||
import com.foxinmy.weixin4j.model.Token;
|
||||
import com.foxinmy.weixin4j.mp.type.URLConsts;
|
||||
import com.foxinmy.weixin4j.token.AbstractTokenCreator;
|
||||
|
||||
/**
|
||||
* 微信公众平台TOKEN创建者
|
||||
*
|
||||
* @className WeixinTokenCreator
|
||||
* @author jy
|
||||
* @date 2015年1月10日
|
||||
* @since JDK 1.6
|
||||
* @see <a
|
||||
* href="https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140183&token=&lang=zh_CN">微信公众平台获取token说明</a>
|
||||
* @see com.foxinmy.weixin4j.model.Token
|
||||
*/
|
||||
public class WeixinTokenCreator extends AbstractTokenCreator {
|
||||
|
||||
private final WeixinRequestExecutor weixinExecutor;
|
||||
private final String appid;
|
||||
private final String secret;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param appid
|
||||
* 公众号ID
|
||||
* @param secret
|
||||
* 公众号secret
|
||||
*/
|
||||
public WeixinTokenCreator(String appid, String secret) {
|
||||
this.appid = appid;
|
||||
this.secret = secret;
|
||||
this.weixinExecutor = new WeixinRequestExecutor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCacheKey0() {
|
||||
return String.format("mp_token_%s", appid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Token createToken() throws WeixinException {
|
||||
String tokenUrl = String.format(URLConsts.ASSESS_TOKEN_URL, appid,
|
||||
secret);
|
||||
WeixinResponse response = weixinExecutor.get(tokenUrl);
|
||||
Token token = response.getAsObject(new TypeReference<Token>() {
|
||||
});
|
||||
token.setOriginalResult(response.getAsString());
|
||||
return token;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,60 +1,56 @@
|
||||
package com.foxinmy.weixin4j.qy.suite;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.foxinmy.weixin4j.exception.WeixinException;
|
||||
import com.foxinmy.weixin4j.http.weixin.WeixinRequestExecutor;
|
||||
import com.foxinmy.weixin4j.http.weixin.WeixinResponse;
|
||||
import com.foxinmy.weixin4j.model.Token;
|
||||
import com.foxinmy.weixin4j.qy.type.URLConsts;
|
||||
import com.foxinmy.weixin4j.token.TokenCreator;
|
||||
import com.foxinmy.weixin4j.token.TokenHolder;
|
||||
|
||||
/**
|
||||
* 微信企业号应用套件预授权码创建
|
||||
*
|
||||
* @className WeixinSuitePreCodeCreator
|
||||
* @author jy
|
||||
* @date 2015年6月17日
|
||||
* @since JDK 1.6
|
||||
* @see <a
|
||||
* href="http://qydev.weixin.qq.com/wiki/index.php?title=%E7%AC%AC%E4%B8%89%E6%96%B9%E5%BA%94%E7%94%A8%E6%8E%A5%E5%8F%A3%E8%AF%B4%E6%98%8E#.E8.8E.B7.E5.8F.96.E9.A2.84.E6.8E.88.E6.9D.83.E7.A0.81">获取应用套件预授权码</a>
|
||||
* @see com.foxinmy.weixin4j.model.Token
|
||||
*/
|
||||
public class WeixinSuitePreCodeCreator implements TokenCreator {
|
||||
|
||||
private final WeixinRequestExecutor weixinExecutor;
|
||||
private final TokenHolder suiteTokenHolder;
|
||||
private final String suiteId;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param suiteTokenHolder
|
||||
* 应用套件的token
|
||||
* @param suiteId
|
||||
* 应用套件ID
|
||||
*/
|
||||
public WeixinSuitePreCodeCreator(TokenHolder suiteTokenHolder,
|
||||
String suiteId) {
|
||||
this.suiteTokenHolder = suiteTokenHolder;
|
||||
this.suiteId = suiteId;
|
||||
this.weixinExecutor = new WeixinRequestExecutor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCacheKey() {
|
||||
return String.format("weixin4j_qy_suite_precode_%s", suiteId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Token createToken() throws WeixinException {
|
||||
WeixinResponse response = weixinExecutor.post(
|
||||
String.format(URLConsts.SUITE_PRE_CODE_URL,
|
||||
suiteTokenHolder.getAccessToken()),
|
||||
String.format("{\"suite_id\":\"%s\"}", suiteId));
|
||||
JSONObject result = response.getAsJson();
|
||||
Token token = new Token(result.getString("pre_auth_code"));
|
||||
token.setExpiresIn(result.getIntValue("expires_in"));
|
||||
token.setOriginalResult(response.getAsString());
|
||||
return token;
|
||||
}
|
||||
}
|
||||
package com.foxinmy.weixin4j.qy.suite;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.foxinmy.weixin4j.exception.WeixinException;
|
||||
import com.foxinmy.weixin4j.http.weixin.WeixinResponse;
|
||||
import com.foxinmy.weixin4j.model.Token;
|
||||
import com.foxinmy.weixin4j.qy.type.URLConsts;
|
||||
import com.foxinmy.weixin4j.token.AbstractTokenCreator;
|
||||
import com.foxinmy.weixin4j.token.TokenHolder;
|
||||
|
||||
/**
|
||||
* 微信企业号应用套件预授权码创建
|
||||
*
|
||||
* @className WeixinSuitePreCodeCreator
|
||||
* @author jy
|
||||
* @date 2015年6月17日
|
||||
* @since JDK 1.6
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E7%AC%AC%E4%B8%89%E6%96%B9%E5%BA%94%E7%94%A8%E6%8E%A5%E5%8F%A3%E8%AF%B4%E6%98%8E#.E8.8E.B7.E5.8F.96.E9.A2.84.E6.8E.88.E6.9D.83.E7.A0.81">
|
||||
* 获取应用套件预授权码</a>
|
||||
* @see com.foxinmy.weixin4j.model.Token
|
||||
*/
|
||||
public class WeixinSuitePreCodeCreator extends AbstractTokenCreator {
|
||||
|
||||
private final TokenHolder suiteTokenHolder;
|
||||
private final String suiteId;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param suiteTokenHolder
|
||||
* 应用套件的token
|
||||
* @param suiteId
|
||||
* 应用套件ID
|
||||
*/
|
||||
public WeixinSuitePreCodeCreator(TokenHolder suiteTokenHolder, String suiteId) {
|
||||
this.suiteTokenHolder = suiteTokenHolder;
|
||||
this.suiteId = suiteId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCacheKey0() {
|
||||
return String.format("qy_suite_precode_%s", suiteId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Token createToken() throws WeixinException {
|
||||
WeixinResponse response = weixinExecutor.post(
|
||||
String.format(URLConsts.SUITE_PRE_CODE_URL, suiteTokenHolder.getAccessToken()),
|
||||
String.format("{\"suite_id\":\"%s\"}", suiteId));
|
||||
JSONObject result = response.getAsJson();
|
||||
Token token = new Token(result.getString("pre_auth_code"));
|
||||
token.setExpiresIn(result.getIntValue("expires_in"));
|
||||
token.setOriginalResult(response.getAsString());
|
||||
return token;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,56 +1,53 @@
|
||||
package com.foxinmy.weixin4j.qy.suite;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.foxinmy.weixin4j.exception.WeixinException;
|
||||
import com.foxinmy.weixin4j.http.weixin.WeixinRequestExecutor;
|
||||
import com.foxinmy.weixin4j.http.weixin.WeixinResponse;
|
||||
import com.foxinmy.weixin4j.model.Token;
|
||||
import com.foxinmy.weixin4j.qy.type.URLConsts;
|
||||
import com.foxinmy.weixin4j.token.TokenCreator;
|
||||
|
||||
/**
|
||||
* 微信企业号应用套件凭证创建
|
||||
*
|
||||
* @className WeixinSuiteTokenCreator
|
||||
* @author jy
|
||||
* @date 2015年6月17日
|
||||
* @since JDK 1.6
|
||||
* @see <a
|
||||
* href="http://qydev.weixin.qq.com/wiki/index.php?title=%E7%AC%AC%E4%B8%89%E6%96%B9%E5%BA%94%E7%94%A8%E6%8E%A5%E5%8F%A3%E8%AF%B4%E6%98%8E#.E8.8E.B7.E5.8F.96.E5.BA.94.E7.94.A8.E5.A5.97.E4.BB.B6.E4.BB.A4.E7.89.8C">获取应用套件凭证</a>
|
||||
* @see com.foxinmy.weixin4j.model.Token
|
||||
*/
|
||||
public class WeixinSuiteTokenCreator implements TokenCreator {
|
||||
|
||||
private final WeixinRequestExecutor weixinExecutor;
|
||||
private final SuiteTicketHolder ticketHolder;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param stringStorager
|
||||
* 套件ticket存取器
|
||||
*/
|
||||
public WeixinSuiteTokenCreator(SuiteTicketHolder ticketHolder) {
|
||||
this.ticketHolder = ticketHolder;
|
||||
this.weixinExecutor = new WeixinRequestExecutor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCacheKey() {
|
||||
return String.format("weixin4j_qy_suite_token_%s", ticketHolder.getSuiteId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Token createToken() throws WeixinException {
|
||||
JSONObject obj = new JSONObject();
|
||||
obj.put("suite_id", ticketHolder.getSuiteId());
|
||||
obj.put("suite_secret", ticketHolder.getSuiteSecret());
|
||||
obj.put("suite_ticket", ticketHolder.getTicket());
|
||||
WeixinResponse response = weixinExecutor.post(URLConsts.SUITE_TOKEN_URL,
|
||||
obj.toJSONString());
|
||||
obj = response.getAsJson();
|
||||
Token token = new Token(obj.getString("suite_access_token"));
|
||||
token.setExpiresIn(obj.getIntValue("expires_in"));
|
||||
token.setOriginalResult(response.getAsString());
|
||||
return token;
|
||||
}
|
||||
}
|
||||
package com.foxinmy.weixin4j.qy.suite;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.foxinmy.weixin4j.exception.WeixinException;
|
||||
import com.foxinmy.weixin4j.http.weixin.WeixinResponse;
|
||||
import com.foxinmy.weixin4j.model.Token;
|
||||
import com.foxinmy.weixin4j.qy.type.URLConsts;
|
||||
import com.foxinmy.weixin4j.token.AbstractTokenCreator;
|
||||
|
||||
/**
|
||||
* 微信企业号应用套件凭证创建
|
||||
*
|
||||
* @className WeixinSuiteTokenCreator
|
||||
* @author jy
|
||||
* @date 2015年6月17日
|
||||
* @since JDK 1.6
|
||||
* @see <a
|
||||
* href="http://qydev.weixin.qq.com/wiki/index.php?title=%E7%AC%AC%E4%B8%89%E6%96%B9%E5%BA%94%E7%94%A8%E6%8E%A5%E5%8F%A3%E8%AF%B4%E6%98%8E#.E8.8E.B7.E5.8F.96.E5.BA.94.E7.94.A8.E5.A5.97.E4.BB.B6.E4.BB.A4.E7.89.8C">获取应用套件凭证</a>
|
||||
* @see com.foxinmy.weixin4j.model.Token
|
||||
*/
|
||||
public class WeixinSuiteTokenCreator extends AbstractTokenCreator {
|
||||
|
||||
private final SuiteTicketHolder ticketHolder;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param stringStorager
|
||||
* 套件ticket存取器
|
||||
*/
|
||||
public WeixinSuiteTokenCreator(SuiteTicketHolder ticketHolder) {
|
||||
this.ticketHolder = ticketHolder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCacheKey0() {
|
||||
return String.format("qy_suite_token_%s", ticketHolder.getSuiteId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Token createToken() throws WeixinException {
|
||||
JSONObject obj = new JSONObject();
|
||||
obj.put("suite_id", ticketHolder.getSuiteId());
|
||||
obj.put("suite_secret", ticketHolder.getSuiteSecret());
|
||||
obj.put("suite_ticket", ticketHolder.getTicket());
|
||||
WeixinResponse response = weixinExecutor.post(URLConsts.SUITE_TOKEN_URL,
|
||||
obj.toJSONString());
|
||||
obj = response.getAsJson();
|
||||
Token token = new Token(obj.getString("suite_access_token"));
|
||||
token.setExpiresIn(obj.getIntValue("expires_in"));
|
||||
token.setOriginalResult(response.getAsString());
|
||||
return token;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,11 +2,10 @@ package com.foxinmy.weixin4j.qy.suite;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.foxinmy.weixin4j.exception.WeixinException;
|
||||
import com.foxinmy.weixin4j.http.weixin.WeixinRequestExecutor;
|
||||
import com.foxinmy.weixin4j.http.weixin.WeixinResponse;
|
||||
import com.foxinmy.weixin4j.model.Token;
|
||||
import com.foxinmy.weixin4j.qy.type.URLConsts;
|
||||
import com.foxinmy.weixin4j.token.TokenCreator;
|
||||
import com.foxinmy.weixin4j.token.AbstractTokenCreator;
|
||||
import com.foxinmy.weixin4j.token.TokenHolder;
|
||||
|
||||
/**
|
||||
@ -16,13 +15,13 @@ import com.foxinmy.weixin4j.token.TokenHolder;
|
||||
* @author jy
|
||||
* @date 2015年6月17日
|
||||
* @since JDK 1.6
|
||||
* @see <a
|
||||
* href="http://qydev.weixin.qq.com/wiki/index.php?title=%E7%AC%AC%E4%B8%89%E6%96%B9%E5%BA%94%E7%94%A8%E6%8E%A5%E5%8F%A3%E8%AF%B4%E6%98%8E#.E8.8E.B7.E5.8F.96.E4.BC.81.E4.B8.9A.E5.8F.B7access_token">获取企业号access_token</a>
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E7%AC%AC%E4%B8%89%E6%96%B9%E5%BA%94%E7%94%A8%E6%8E%A5%E5%8F%A3%E8%AF%B4%E6%98%8E#.E8.8E.B7.E5.8F.96.E4.BC.81.E4.B8.9A.E5.8F.B7access_token">
|
||||
* 获取企业号access_token</a>
|
||||
* @see com.foxinmy.weixin4j.model.Token
|
||||
*/
|
||||
public class WeixinTokenSuiteCreator implements TokenCreator {
|
||||
public class WeixinTokenSuiteCreator extends AbstractTokenCreator {
|
||||
|
||||
private final WeixinRequestExecutor weixinExecutor;
|
||||
private final SuitePerCodeHolder perCodeHolder;
|
||||
private final TokenHolder suiteTokenHolder;
|
||||
|
||||
@ -33,19 +32,14 @@ public class WeixinTokenSuiteCreator implements TokenCreator {
|
||||
* @param suiteTokenHolder
|
||||
* 第三方套件凭证token
|
||||
*/
|
||||
public WeixinTokenSuiteCreator(SuitePerCodeHolder perCodeHolder,
|
||||
TokenHolder suiteTokenHolder) {
|
||||
public WeixinTokenSuiteCreator(SuitePerCodeHolder perCodeHolder, TokenHolder suiteTokenHolder) {
|
||||
this.perCodeHolder = perCodeHolder;
|
||||
this.suiteTokenHolder = suiteTokenHolder;
|
||||
this.weixinExecutor = new WeixinRequestExecutor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCacheKey() {
|
||||
return String.format("weixin4j_qy_token_suite_%s_%s",
|
||||
perCodeHolder.getSuiteId(), perCodeHolder.getAuthCorpId()
|
||||
|
||||
);
|
||||
public String getCacheKey0() {
|
||||
return String.format("qy_token_suite_%s_%s", perCodeHolder.getSuiteId(), perCodeHolder.getAuthCorpId());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -54,9 +48,8 @@ public class WeixinTokenSuiteCreator implements TokenCreator {
|
||||
obj.put("suite_id", perCodeHolder.getSuiteId());
|
||||
obj.put("auth_corpid", perCodeHolder.getAuthCorpId());
|
||||
obj.put("permanent_code", perCodeHolder.getPermanentCode());
|
||||
WeixinResponse response = weixinExecutor.post(
|
||||
String.format(URLConsts.TOKEN_SUITE_URL,
|
||||
suiteTokenHolder.getAccessToken()), obj.toJSONString());
|
||||
WeixinResponse response = weixinExecutor
|
||||
.post(String.format(URLConsts.TOKEN_SUITE_URL, suiteTokenHolder.getAccessToken()), obj.toJSONString());
|
||||
obj = response.getAsJson();
|
||||
Token token = new Token(obj.getString("access_token"));
|
||||
token.setExpiresIn(obj.getIntValue("expires_in"));
|
||||
|
||||
@ -1,59 +1,56 @@
|
||||
package com.foxinmy.weixin4j.qy.token;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.foxinmy.weixin4j.exception.WeixinException;
|
||||
import com.foxinmy.weixin4j.http.weixin.WeixinRequestExecutor;
|
||||
import com.foxinmy.weixin4j.http.weixin.WeixinResponse;
|
||||
import com.foxinmy.weixin4j.model.Token;
|
||||
import com.foxinmy.weixin4j.qy.type.URLConsts;
|
||||
import com.foxinmy.weixin4j.token.TokenCreator;
|
||||
|
||||
/**
|
||||
* 微信企业号应用提供商凭证创建
|
||||
*
|
||||
* @className WeixinTokenCreator
|
||||
* @author jy
|
||||
* @date 2015年1月10日
|
||||
* @since JDK 1.6
|
||||
* @see <a
|
||||
* href="http://qydev.weixin.qq.com/wiki/index.php?title=%E8%8E%B7%E5%8F%96%E5%BA%94%E7%94%A8%E6%8F%90%E4%BE%9B%E5%95%86%E5%87%AD%E8%AF%81">获取应用提供商凭证</a>
|
||||
* @see com.foxinmy.weixin4j.model.Token
|
||||
*/
|
||||
public class WeixinProviderTokenCreator implements TokenCreator {
|
||||
|
||||
private final WeixinRequestExecutor weixinExecutor;
|
||||
private final String corpid;
|
||||
private final String providersecret;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param corpid
|
||||
* 企业号ID
|
||||
* @param providersecret
|
||||
* 企业号提供商的secret
|
||||
*/
|
||||
public WeixinProviderTokenCreator(String corpid, String providersecret) {
|
||||
this.corpid = corpid;
|
||||
this.providersecret = providersecret;
|
||||
this.weixinExecutor = new WeixinRequestExecutor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCacheKey() {
|
||||
return String.format("weixin4j_qy_provider_token_%s", corpid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Token createToken() throws WeixinException {
|
||||
JSONObject obj = new JSONObject();
|
||||
obj.put("corpid", corpid);
|
||||
obj.put("provider_secret", providersecret);
|
||||
WeixinResponse response = weixinExecutor.post(URLConsts.PROVIDER_TOKEN_URL,
|
||||
obj.toJSONString());
|
||||
obj = response.getAsJson();
|
||||
Token token = new Token(obj.getString("provider_access_token"));
|
||||
token.setExpiresIn(obj.getIntValue("expires_in"));
|
||||
token.setOriginalResult(response.getAsString());
|
||||
return token;
|
||||
}
|
||||
}
|
||||
package com.foxinmy.weixin4j.qy.token;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.foxinmy.weixin4j.exception.WeixinException;
|
||||
import com.foxinmy.weixin4j.http.weixin.WeixinResponse;
|
||||
import com.foxinmy.weixin4j.model.Token;
|
||||
import com.foxinmy.weixin4j.qy.type.URLConsts;
|
||||
import com.foxinmy.weixin4j.token.AbstractTokenCreator;
|
||||
|
||||
/**
|
||||
* 微信企业号应用提供商凭证创建
|
||||
*
|
||||
* @className WeixinTokenCreator
|
||||
* @author jy
|
||||
* @date 2015年1月10日
|
||||
* @since JDK 1.6
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E8%8E%B7%E5%8F%96%E5%BA%94%E7%94%A8%E6%8F%90%E4%BE%9B%E5%95%86%E5%87%AD%E8%AF%81">
|
||||
* 获取应用提供商凭证</a>
|
||||
* @see com.foxinmy.weixin4j.model.Token
|
||||
*/
|
||||
public class WeixinProviderTokenCreator extends AbstractTokenCreator {
|
||||
|
||||
private final String corpid;
|
||||
private final String providersecret;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param corpid
|
||||
* 企业号ID
|
||||
* @param providersecret
|
||||
* 企业号提供商的secret
|
||||
*/
|
||||
public WeixinProviderTokenCreator(String corpid, String providersecret) {
|
||||
this.corpid = corpid;
|
||||
this.providersecret = providersecret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCacheKey0() {
|
||||
return String.format("qy_provider_token_%s", corpid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Token createToken() throws WeixinException {
|
||||
JSONObject obj = new JSONObject();
|
||||
obj.put("corpid", corpid);
|
||||
obj.put("provider_secret", providersecret);
|
||||
WeixinResponse response = weixinExecutor.post(URLConsts.PROVIDER_TOKEN_URL, obj.toJSONString());
|
||||
obj = response.getAsJson();
|
||||
Token token = new Token(obj.getString("provider_access_token"));
|
||||
token.setExpiresIn(obj.getIntValue("expires_in"));
|
||||
token.setOriginalResult(response.getAsString());
|
||||
return token;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,11 +2,10 @@ package com.foxinmy.weixin4j.qy.token;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.foxinmy.weixin4j.exception.WeixinException;
|
||||
import com.foxinmy.weixin4j.http.weixin.WeixinRequestExecutor;
|
||||
import com.foxinmy.weixin4j.http.weixin.WeixinResponse;
|
||||
import com.foxinmy.weixin4j.model.Token;
|
||||
import com.foxinmy.weixin4j.qy.type.URLConsts;
|
||||
import com.foxinmy.weixin4j.token.TokenCreator;
|
||||
import com.foxinmy.weixin4j.token.AbstractTokenCreator;
|
||||
import com.foxinmy.weixin4j.token.TokenHolder;
|
||||
import com.foxinmy.weixin4j.type.TicketType;
|
||||
|
||||
@ -20,12 +19,11 @@ import com.foxinmy.weixin4j.type.TicketType;
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E5%BE%AE%E4%BF%A1JS-SDK%E6%8E%A5%E5%8F%A3#.E9.99.84.E5.BD.951-JS-SDK.E4.BD.BF.E7.94.A8.E6.9D.83.E9.99.90.E7.AD.BE.E5.90.8D.E7.AE.97.E6.B3.95"
|
||||
* >JSTICKET</a>
|
||||
*/
|
||||
public class WeixinTicketCreator implements TokenCreator {
|
||||
public class WeixinTicketCreator extends AbstractTokenCreator {
|
||||
|
||||
private final String corpid;
|
||||
private final TicketType ticketType;
|
||||
private final TokenHolder weixinTokenHolder;
|
||||
private final WeixinRequestExecutor weixinExecutor;
|
||||
|
||||
/**
|
||||
* @param corpid
|
||||
@ -39,12 +37,11 @@ public class WeixinTicketCreator implements TokenCreator {
|
||||
this.corpid = corpid;
|
||||
this.ticketType = ticketType;
|
||||
this.weixinTokenHolder = weixinTokenHolder;
|
||||
this.weixinExecutor = new WeixinRequestExecutor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCacheKey() {
|
||||
return String.format("weixin4j_qy_ticket_%s_%s", ticketType.name(), corpid);
|
||||
public String getCacheKey0() {
|
||||
return String.format("qy_ticket_%s_%s", ticketType.name(), corpid);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -1,56 +1,56 @@
|
||||
package com.foxinmy.weixin4j.qy.token;
|
||||
|
||||
import com.alibaba.fastjson.TypeReference;
|
||||
import com.foxinmy.weixin4j.exception.WeixinException;
|
||||
import com.foxinmy.weixin4j.http.weixin.WeixinRequestExecutor;
|
||||
import com.foxinmy.weixin4j.http.weixin.WeixinResponse;
|
||||
import com.foxinmy.weixin4j.model.Token;
|
||||
import com.foxinmy.weixin4j.qy.type.URLConsts;
|
||||
import com.foxinmy.weixin4j.token.TokenCreator;
|
||||
|
||||
/**
|
||||
* 微信企业号TOKEN创建
|
||||
*
|
||||
* @className WeixinTokenCreator
|
||||
* @author jy
|
||||
* @date 2015年1月10日
|
||||
* @since JDK 1.6
|
||||
* @see <a
|
||||
* href="http://qydev.weixin.qq.com/wiki/index.php?title=%E4%B8%BB%E5%8A%A8%E8%B0%83%E7%94%A8">微信企业号获取token说明</a>
|
||||
* @see com.foxinmy.weixin4j.model.Token
|
||||
*/
|
||||
public class WeixinTokenCreator implements TokenCreator {
|
||||
|
||||
private final WeixinRequestExecutor weixinExecutor;
|
||||
private final String corpid;
|
||||
private final String corpsecret;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param corpid
|
||||
* 企业号ID
|
||||
* @param corpsecret
|
||||
* 企业号secret
|
||||
*/
|
||||
public WeixinTokenCreator(String corpid, String corpsecret) {
|
||||
this.corpid = corpid;
|
||||
this.corpsecret = corpsecret;
|
||||
this.weixinExecutor = new WeixinRequestExecutor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCacheKey() {
|
||||
return String.format("weixin4j_qy_token_%s", corpid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Token createToken() throws WeixinException {
|
||||
String tokenUrl = String.format(URLConsts.ASSESS_TOKEN_URL, corpid,
|
||||
corpsecret);
|
||||
WeixinResponse response = weixinExecutor.get(tokenUrl);
|
||||
Token token = response.getAsObject(new TypeReference<Token>() {
|
||||
});
|
||||
token.setOriginalResult(response.getAsString());
|
||||
return token;
|
||||
}
|
||||
}
|
||||
package com.foxinmy.weixin4j.qy.token;
|
||||
|
||||
import com.alibaba.fastjson.TypeReference;
|
||||
import com.foxinmy.weixin4j.exception.WeixinException;
|
||||
import com.foxinmy.weixin4j.http.weixin.WeixinRequestExecutor;
|
||||
import com.foxinmy.weixin4j.http.weixin.WeixinResponse;
|
||||
import com.foxinmy.weixin4j.model.Token;
|
||||
import com.foxinmy.weixin4j.qy.type.URLConsts;
|
||||
import com.foxinmy.weixin4j.token.AbstractTokenCreator;
|
||||
|
||||
/**
|
||||
* 微信企业号TOKEN创建
|
||||
*
|
||||
* @className WeixinTokenCreator
|
||||
* @author jy
|
||||
* @date 2015年1月10日
|
||||
* @since JDK 1.6
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E4%B8%BB%E5%8A%A8%E8%B0%83%E7%94%A8">
|
||||
* 微信企业号获取token说明</a>
|
||||
* @see com.foxinmy.weixin4j.model.Token
|
||||
*/
|
||||
public class WeixinTokenCreator extends AbstractTokenCreator {
|
||||
|
||||
private final WeixinRequestExecutor weixinExecutor;
|
||||
private final String corpid;
|
||||
private final String corpsecret;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param corpid
|
||||
* 企业号ID
|
||||
* @param corpsecret
|
||||
* 企业号secret
|
||||
*/
|
||||
public WeixinTokenCreator(String corpid, String corpsecret) {
|
||||
this.corpid = corpid;
|
||||
this.corpsecret = corpsecret;
|
||||
this.weixinExecutor = new WeixinRequestExecutor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCacheKey0() {
|
||||
return String.format("qy_token_%s", corpid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Token createToken() throws WeixinException {
|
||||
String tokenUrl = String.format(URLConsts.ASSESS_TOKEN_URL, corpid, corpsecret);
|
||||
WeixinResponse response = weixinExecutor.get(tokenUrl);
|
||||
Token token = response.getAsObject(new TypeReference<Token>() {
|
||||
});
|
||||
token.setOriginalResult(response.getAsString());
|
||||
return token;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user