|
|
@@ -511,26 +511,22 @@ public class WxProviderServiceImpl implements WxProviderService {
|
|
|
}
|
|
|
|
|
|
|
|
|
+ @SneakyThrows
|
|
|
public static String traceWaybill(TraceWaybill traceWaybill) {
|
|
|
AccessToken accessToken = AccessTokenApi.getAccessToken(WxConstants.APPLET_APPID, WxConstants.APPLET_SECRET);
|
|
|
String url = "https://api.weixin.qq.com/cgi-bin/express/delivery/open_msg/trace_waybill?access_token=" + accessToken.getToken();
|
|
|
- try {
|
|
|
- CloseableHttpClient httpClient = HttpClients.createDefault();
|
|
|
- HttpPost httpPost = new HttpPost(url);
|
|
|
- httpPost.addHeader("Content-Type", "application/json");
|
|
|
- StringEntity requestBody = new StringEntity(new Gson().toJson(traceWaybill), ContentType.APPLICATION_JSON.withCharset("UTF-8"));
|
|
|
- httpPost.setEntity(requestBody);
|
|
|
- CloseableHttpResponse response = httpClient.execute(httpPost);
|
|
|
- HttpEntity responseEntity = response.getEntity();
|
|
|
- String responseString = EntityUtils.toString(responseEntity, "UTF-8");
|
|
|
- log.info(responseString);
|
|
|
- response.close();
|
|
|
- httpClient.close();
|
|
|
- return responseString;
|
|
|
- } catch (IOException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- return "";
|
|
|
+ CloseableHttpClient httpClient = HttpClients.createDefault();
|
|
|
+ HttpPost httpPost = new HttpPost(url);
|
|
|
+ httpPost.addHeader("Content-Type", "application/json");
|
|
|
+ StringEntity requestBody = new StringEntity(new Gson().toJson(traceWaybill), ContentType.APPLICATION_JSON.withCharset("UTF-8"));
|
|
|
+ httpPost.setEntity(requestBody);
|
|
|
+ CloseableHttpResponse response = httpClient.execute(httpPost);
|
|
|
+ HttpEntity responseEntity = response.getEntity();
|
|
|
+ String responseString = EntityUtils.toString(responseEntity, "UTF-8");
|
|
|
+ log.info(responseString);
|
|
|
+ response.close();
|
|
|
+ httpClient.close();
|
|
|
+ return responseString;
|
|
|
}
|
|
|
|
|
|
public static void main(String[] args) {
|