| @@ -32,6 +32,7 @@ import org.apache.http.impl.client.CloseableHttpClient; | |||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.lang.reflect.Field; | import java.lang.reflect.Field; | ||||
| import java.nio.charset.Charset; | |||||
| import java.util.HashMap; | import java.util.HashMap; | ||||
| import java.util.Map; | import java.util.Map; | ||||
| import java.util.concurrent.locks.Lock; | import java.util.concurrent.locks.Lock; | ||||
| @@ -110,7 +111,11 @@ public class TtWebServiceImpl implements TtWebService, RequestHttp<CloseableHttp | |||||
| params.put("client_secret", this.getTtWebConfig().getSecret()); | params.put("client_secret", this.getTtWebConfig().getSecret()); | ||||
| params.put("grant_type", "client_credential"); | params.put("grant_type", "client_credential"); | ||||
| try { | try { | ||||
| String apiUrl = this.getTtWebConfig().getApiBegin().getPrefix() + this.POST_ACCESS_TOKEN_URL; | |||||
| String apiUrl = this.getTtWebConfig().getApiBegin().getPrefix() + this.POST_ACCESS_TOKEN_URL | |||||
| + "?client_key="+this.getTtWebConfig().getAppid() | |||||
| + "&client_secret="+this.getTtWebConfig().getSecret() | |||||
| + "&grant_type=client_credential"; | |||||
| HttpPost httpPost = new HttpPost(apiUrl); | HttpPost httpPost = new HttpPost(apiUrl); | ||||
| if (this.getRequestHttpProxy() != null) { | if (this.getRequestHttpProxy() != null) { | ||||
| RequestConfig config = RequestConfig.custom().setProxy(this.getRequestHttpProxy()).build(); | RequestConfig config = RequestConfig.custom().setProxy(this.getRequestHttpProxy()).build(); | ||||
| @@ -118,13 +123,14 @@ public class TtWebServiceImpl implements TtWebService, RequestHttp<CloseableHttp | |||||
| } | } | ||||
| httpPost.setHeader("Content-Type","multipart/form-data"); | httpPost.setHeader("Content-Type","multipart/form-data"); | ||||
| MultipartEntityBuilder builder = MultipartEntityBuilder.create(); | |||||
| builder.addTextBody("client_key", this.getTtWebConfig().getAppid(), ContentType.MULTIPART_FORM_DATA); | |||||
| builder.addTextBody("client_secret", this.getTtWebConfig().getSecret(), ContentType.MULTIPART_FORM_DATA); | |||||
| builder.addTextBody("client_key", "client_credential", ContentType.MULTIPART_FORM_DATA); | |||||
| HttpEntity multipart = builder.build(); | |||||
| httpPost.setEntity(multipart); | |||||
| // MultipartEntityBuilder builder = MultipartEntityBuilder.create(); | |||||
| // builder.setCharset(Charset.forName("utf-8")); | |||||
| // builder.addTextBody("client_key", this.getTtWebConfig().getAppid()); | |||||
| // builder.addTextBody("client_secret", this.getTtWebConfig().getSecret()); | |||||
| // builder.addTextBody("client_key", "client_credential"); | |||||
| // | |||||
| // HttpEntity multipart = builder.build(); | |||||
| // httpPost.setEntity(multipart); | |||||
| // log.info("------------"+WxGsonBuilder.create().toJson(params)); | // log.info("------------"+WxGsonBuilder.create().toJson(params)); | ||||
| // StringEntity entity = new StringEntity(WxGsonBuilder.create().toJson(params), Consts.UTF_8); | // StringEntity entity = new StringEntity(WxGsonBuilder.create().toJson(params), Consts.UTF_8); | ||||