新增手动刷新token方法 #12

This commit is contained in:
jinyu 2015-09-27 21:36:05 +08:00
parent 8f0ddd421c
commit 12fdf6065b
7 changed files with 27 additions and 8 deletions

View File

@ -477,4 +477,8 @@
+ weixin4j-[mp|qy]:version upgrade to 1.6.2 + weixin4j-[mp|qy]:version upgrade to 1.6.2
+ weixin4j-server:version upgrade to 1.1.2 + weixin4j-server:version upgrade to 1.1.2
* 2015-09-27
+ 新增手动刷新token方法

View File

@ -26,14 +26,14 @@ weixin4j
如何获取 如何获取
---------- ----------
###1.maven依赖 ###1.maven依赖
微信公众平台API(1.6.2,2015-09-21 released) 微信公众平台API(1.6.2,2015-09-27 released)
<dependency> <dependency>
<groupId>com.foxinmy</groupId> <groupId>com.foxinmy</groupId>
<artifactId>weixin4j-mp</artifactId> <artifactId>weixin4j-mp</artifactId>
<version>1.6.2</version> <version>1.6.2</version>
</dependency> </dependency>
微信企业号API(1.6.2,2015-09-21 released) 微信企业号API(1.6.2,2015-09-27 released)
<dependency> <dependency>
<groupId>com.foxinmy</groupId> <groupId>com.foxinmy</groupId>

View File

@ -64,4 +64,8 @@
* 2015-08-01 * 2015-08-01
+ 整理了Tuple消息元件并新增ChatTuple企业号聊天消息元件 + 整理了Tuple消息元件并新增ChatTuple企业号聊天消息元件
* 2015-09-27
+ 新增手动刷新token方法

View File

@ -61,4 +61,17 @@ public final class TokenHolder {
public String getAccessToken() throws WeixinException { public String getAccessToken() throws WeixinException {
return getToken().getAccessToken(); return getToken().getAccessToken();
} }
/**
* 手动刷新token
*
* @return 刷新后的token
* @throws WeixinException
*/
public Token refreshToken() throws WeixinException {
String cacheKey = tokenCreator.getCacheKey();
Token token = tokenCreator.createToken();
tokenStorager.caching(cacheKey, token);
return token;
}
} }

View File

@ -12,7 +12,6 @@ import com.foxinmy.weixin4j.http.HttpParams;
import com.foxinmy.weixin4j.http.HttpRequest; import com.foxinmy.weixin4j.http.HttpRequest;
import com.foxinmy.weixin4j.http.HttpResponse; import com.foxinmy.weixin4j.http.HttpResponse;
import com.foxinmy.weixin4j.http.factory.HttpClientFactory; import com.foxinmy.weixin4j.http.factory.HttpClientFactory;
import com.foxinmy.weixin4j.http.factory.HttpComponent3Factory;
import com.foxinmy.weixin4j.http.factory.HttpComponent4Factory; import com.foxinmy.weixin4j.http.factory.HttpComponent4Factory;
import com.foxinmy.weixin4j.util.IOUtil; import com.foxinmy.weixin4j.util.IOUtil;
@ -34,7 +33,6 @@ public class HttpClientTest {
} }
public static void test2() throws HttpClientException { public static void test2() throws HttpClientException {
HttpClientFactory.setDefaultFactory(new HttpComponent3Factory());
HttpClient httpClient = HttpClientFactory.getInstance(); HttpClient httpClient = HttpClientFactory.getInstance();
HttpResponse response = httpClient.execute(request); HttpResponse response = httpClient.execute(request);
print(response); print(response);

View File

@ -43,7 +43,7 @@ weixin4j-mp
如何使用 如何使用
-------- --------
0.maven依赖(1.6.2,2015-09-21 released) 0.maven依赖(1.6.2,2015-09-27 released)
<dependency> <dependency>
<groupId>com.foxinmy</groupId> <groupId>com.foxinmy</groupId>

View File

@ -37,7 +37,7 @@ weixin4j-qy
如何使用 如何使用
-------- --------
0.maven依赖(1.6.2,2015-09-21 released) 0.maven依赖(1.6.2,2015-09-27 released)
<dependency> <dependency>
<groupId>com.foxinmy</groupId> <groupId>com.foxinmy</groupId>