admin
2019-11-05 bc3a51600e5b950b8042e13c2fc5e4aa943ffc29
utils/src/main/java/org/yeshi/utils/HttpUtil.java
@@ -59,13 +59,13 @@
   }
   public static String getShortLink(String url) {
      return url;
//       String shortLink = getShortLink3(url);
//       if (StringUtil.isNullOrEmpty(shortLink))
//       shortLink = getShortLink1(url);
//       if (StringUtil.isNullOrEmpty(shortLink))
//       shortLink = getShortLink2(url);
//       return shortLink;
      // return url;
      String shortLink = getShortLink3(url);
      if (StringUtil.isNullOrEmpty(shortLink))
         shortLink = getShortLink1(url);
      if (StringUtil.isNullOrEmpty(shortLink))
         shortLink = getShortLink2(url);
      return shortLink;
   }
   private static String getShortLink1(String url) {
@@ -101,8 +101,7 @@
   private static String getShortLink3(String url) {
      try {
         String totalUrl = String.format(
               "http://h5.flq001.com/short/createShort?url=%s",
         String totalUrl = String.format("http://h5.flq001.com/short/createShort?url=%s",
               URLEncoder.encode(url, "UTF-8"));
         String result = get(totalUrl, null);
         JSONObject data = JSONObject.fromObject(result);
@@ -584,4 +583,25 @@
      return result;
   }
   /**
    * 获取post返回location
    * @param url
    * @return
    */
   public static String getLocation(String url) {
      HttpClient client = new HttpClient();
      PostMethod method = new PostMethod(url);
      try {
         client.executeMethod(method);
            return method.getResponseHeader("location").getValue();
      } catch (HttpException e) {
         e.printStackTrace();
      } catch (IOException e) {
         e.printStackTrace();
      }
      return null;
   }
}