diff --git a/panda-code/src/main/java/org/panda/code/uitl/http/HttpsClient.java b/panda-code/src/main/java/org/panda/code/uitl/http/HttpsClient.java index 6280d50..30f6813 100644 --- a/panda-code/src/main/java/org/panda/code/uitl/http/HttpsClient.java +++ b/panda-code/src/main/java/org/panda/code/uitl/http/HttpsClient.java @@ -39,7 +39,7 @@ public class HttpsClient { String resultStr = ""; try{ // 获得utf-8编码的mbuilder - MultipartEntityBuilder mBuilder = get_COMPATIBLE_Builder(DETAFILE_CHARSET,boundary); + MultipartEntityBuilder mBuilder = getCompatibleBuilder(DETAFILE_CHARSET,boundary); /** * 原生的微信使用的url是https://api.weixin.qq.com/cgi-bin/media/upload? * access_token=##ACCESS_TOKEN##&type=##TYPE## @@ -79,8 +79,6 @@ public class HttpsClient { reponse = client.execute(post); // 获得返回的内容 HttpEntity entity = reponse.getEntity(); - // 输出 - System.out.println(JSONObject.toJSONString(entity)); resultStr = JSONObject.toJSONString(entity); @@ -90,7 +88,6 @@ public class HttpsClient { while (reader.ready()){ buffer.append((char)reader.read()); } - System.out.println(buffer.toString()); } catch (ClientProtocolException e) { e.printStackTrace(); } catch (IOException e) { @@ -118,7 +115,7 @@ public class HttpsClient { } - private static MultipartEntityBuilder get_COMPATIBLE_Builder(String charSet,String boundarStr) { + private static MultipartEntityBuilder getCompatibleBuilder(String charSet,String boundarStr) { MultipartEntityBuilder result = MultipartEntityBuilder.create(); result.setBoundary(boundarStr) .setCharset(Charset.forName(charSet)) @@ -158,18 +155,5 @@ public class HttpsClient { SSLContext context = SSLContext.getDefault(); return context; } - - public static void main(String[] args) throws IOException { - File file =new File("/Users/qi_liang/Downloads/timg.jpeg"); - String url = "https://api.weixin.qq.com/cgi-bin/media/upload"; - Map params = new HashMap(); - params.put("access_token", "10_0oKKCsF9JL30JeGZDyfNWDhiaRvivAL9vs9ihvaledzBuPVM6IMvwcFUc58AFwlETRdvEBAFXOYbF2GoKmbtMmopCs78m9UE8whgrYU4kJww4mSooMcq8el-qnU4JdjPGKruZLjdNS246hXyWOHbAAAHZS"); - params.put("type", "image"); - if(file.exists()){ - params.put("media", file); - } - String resultStr = post(url,params); - System.out.println(resultStr); - } - + }