|
|
|
@@ -16,6 +16,8 @@ import org.apache.http.client.config.RequestConfig; |
|
|
|
import org.apache.http.client.methods.CloseableHttpResponse; |
|
|
|
import org.apache.http.client.methods.HttpGet; |
|
|
|
import org.apache.http.impl.client.CloseableHttpClient; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
|
|
|
|
import java.io.IOException; |
|
|
|
import java.util.regex.Matcher; |
|
|
|
@@ -27,8 +29,9 @@ import java.util.regex.Pattern; |
|
|
|
* @author ecoolper |
|
|
|
* @date 2017/5/4 |
|
|
|
*/ |
|
|
|
@Slf4j |
|
|
|
public class TtWebGetRequestExecutor implements RequestExecutor<String, String> { |
|
|
|
private final Logger logger = LoggerFactory.getLogger(this.getClass()); |
|
|
|
|
|
|
|
protected RequestHttp<CloseableHttpClient, HttpHost> requestHttp; |
|
|
|
|
|
|
|
public TtWebGetRequestExecutor(RequestHttp requestHttp) { |
|
|
|
@@ -42,8 +45,8 @@ public class TtWebGetRequestExecutor implements RequestExecutor<String, String> |
|
|
|
|
|
|
|
@Override |
|
|
|
public String execute(String uri, String queryParam, WxType wxType) throws WxErrorException, IOException { |
|
|
|
log.info("uri{}"+uri); |
|
|
|
log.info("request{}"+queryParam); |
|
|
|
logger.info("uri{}"+uri); |
|
|
|
logger.info("request{}"+queryParam); |
|
|
|
String access_token = handleUrl(uri); |
|
|
|
if(StringUtils.isBlank(access_token)){ |
|
|
|
WxError wxError = WxError.fromJson("{\n" + |
|
|
|
@@ -70,7 +73,7 @@ public class TtWebGetRequestExecutor implements RequestExecutor<String, String> |
|
|
|
|
|
|
|
try (CloseableHttpResponse response = requestHttp.getRequestHttpClient().execute(httpGet)) { |
|
|
|
String responseContent = Utf8ResponseHandler.INSTANCE.handleResponse(response); |
|
|
|
log.info("response{}"+responseContent); |
|
|
|
logger.info("response{}"+responseContent); |
|
|
|
JSONObject jsonObject = JSON.parseObject(responseContent); |
|
|
|
JSONObject data = jsonObject.getJSONObject("data"); |
|
|
|
WxError error = WxError.fromJson(data.toJSONString()); |
|
|
|
|