mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-08-25 01:14:36 +08:00
parent
06e4dda310
commit
d759e6935e
@ -158,14 +158,15 @@ public class WxMpServiceImpl implements WxMpService {
|
|||||||
RequestConfig config = RequestConfig.custom().setProxy(httpProxy).build();
|
RequestConfig config = RequestConfig.custom().setProxy(httpProxy).build();
|
||||||
httpGet.setConfig(config);
|
httpGet.setConfig(config);
|
||||||
}
|
}
|
||||||
CloseableHttpResponse response = getHttpclient().execute(httpGet);
|
try (CloseableHttpResponse response = getHttpclient().execute(httpGet)) {
|
||||||
String resultContent = new BasicResponseHandler().handleResponse(response);
|
String resultContent = new BasicResponseHandler().handleResponse(response);
|
||||||
WxError error = WxError.fromJson(resultContent);
|
WxError error = WxError.fromJson(resultContent);
|
||||||
if (error.getErrorCode() != 0) {
|
if (error.getErrorCode() != 0) {
|
||||||
throw new WxErrorException(error);
|
throw new WxErrorException(error);
|
||||||
|
}
|
||||||
|
WxAccessToken accessToken = WxAccessToken.fromJson(resultContent);
|
||||||
|
wxMpConfigStorage.updateAccessToken(accessToken.getAccessToken(), accessToken.getExpiresIn());
|
||||||
}
|
}
|
||||||
WxAccessToken accessToken = WxAccessToken.fromJson(resultContent);
|
|
||||||
wxMpConfigStorage.updateAccessToken(accessToken.getAccessToken(), accessToken.getExpiresIn());
|
|
||||||
} catch (ClientProtocolException e) {
|
} catch (ClientProtocolException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@ -851,8 +852,7 @@ public class WxMpServiceImpl implements WxMpService {
|
|||||||
|
|
||||||
StringEntity entity = new StringEntity(request.toString(), Consts.UTF_8);
|
StringEntity entity = new StringEntity(request.toString(), Consts.UTF_8);
|
||||||
httpPost.setEntity(entity);
|
httpPost.setEntity(entity);
|
||||||
try {
|
try(CloseableHttpResponse response = getHttpclient().execute(httpPost)) {
|
||||||
CloseableHttpResponse response = getHttpclient().execute(httpPost);
|
|
||||||
String responseContent = Utf8ResponseHandler.INSTANCE.handleResponse(response);
|
String responseContent = Utf8ResponseHandler.INSTANCE.handleResponse(response);
|
||||||
XStream xstream = XStreamInitializer.getInstance();
|
XStream xstream = XStreamInitializer.getInstance();
|
||||||
xstream.alias("xml", WxMpPrepayIdResult.class);
|
xstream.alias("xml", WxMpPrepayIdResult.class);
|
||||||
@ -944,8 +944,7 @@ public class WxMpServiceImpl implements WxMpService {
|
|||||||
|
|
||||||
StringEntity entity = new StringEntity(request.toString(), Consts.UTF_8);
|
StringEntity entity = new StringEntity(request.toString(), Consts.UTF_8);
|
||||||
httpPost.setEntity(entity);
|
httpPost.setEntity(entity);
|
||||||
try {
|
try(CloseableHttpResponse response = httpClient.execute(httpPost)) {
|
||||||
CloseableHttpResponse response = httpClient.execute(httpPost);
|
|
||||||
String responseContent = Utf8ResponseHandler.INSTANCE.handleResponse(response);
|
String responseContent = Utf8ResponseHandler.INSTANCE.handleResponse(response);
|
||||||
XStream xstream = XStreamInitializer.getInstance();
|
XStream xstream = XStreamInitializer.getInstance();
|
||||||
xstream.alias("xml", WxMpPayResult.class);
|
xstream.alias("xml", WxMpPayResult.class);
|
||||||
@ -1000,8 +999,7 @@ public class WxMpServiceImpl implements WxMpService {
|
|||||||
|
|
||||||
StringEntity entity = new StringEntity(request.toString(), Consts.UTF_8);
|
StringEntity entity = new StringEntity(request.toString(), Consts.UTF_8);
|
||||||
httpPost.setEntity(entity);
|
httpPost.setEntity(entity);
|
||||||
try {
|
try(CloseableHttpResponse response = getHttpclient().execute(httpPost)) {
|
||||||
CloseableHttpResponse response = getHttpclient().execute(httpPost);
|
|
||||||
String responseContent = Utf8ResponseHandler.INSTANCE.handleResponse(response);
|
String responseContent = Utf8ResponseHandler.INSTANCE.handleResponse(response);
|
||||||
XStream xstream = XStreamInitializer.getInstance();
|
XStream xstream = XStreamInitializer.getInstance();
|
||||||
xstream.processAnnotations(WxRedpackResult.class);
|
xstream.processAnnotations(WxRedpackResult.class);
|
||||||
|
Loading…
Reference in New Issue
Block a user