From 565c0a03a299de5a619f4d5b5fe593e46dbf35dd Mon Sep 17 00:00:00 2001
From: yujian <yujian@123.com>
Date: 星期三, 28 八月 2019 15:07:58 +0800
Subject: [PATCH] Merge branch 'div' of ssh://193.112.35.168:29418/fanli-server into div

---
 utils/src/main/java/org/yeshi/utils/HttpUtil.java |   28 +++++++++-------------------
 1 files changed, 9 insertions(+), 19 deletions(-)

diff --git a/utils/src/main/java/org/yeshi/utils/HttpUtil.java b/utils/src/main/java/org/yeshi/utils/HttpUtil.java
index d1fbf3f..f1cc3bd 100644
--- a/utils/src/main/java/org/yeshi/utils/HttpUtil.java
+++ b/utils/src/main/java/org/yeshi/utils/HttpUtil.java
@@ -52,7 +52,7 @@
 		return "";
 	}
 
-	public static String getShortLink(String url) {
+	public static String getShortLink(String url) {
 		String shortLink = getShortLink2(url);
 		if (StringUtil.isNullOrEmpty(shortLink))
 			shortLink = getShortLink3(url);
@@ -76,15 +76,11 @@
 	private static String getShortLink2(String url) {
 		try {
 			String totalUrl = String.format(
-					"https://api.weibo.com/2/short_url/shorten.json?source=3403499693&url_long=%s",
+					"http://api.t.sina.com.cn/short_url/shorten.json?source=3403499693&url_long=%s",
 					URLEncoder.encode(url));
 			String result = get(totalUrl, null);
-			JSONObject data = JSONObject.fromObject(result);
-			JSONArray array = data.optJSONArray("urls");
-			data = array.optJSONObject(0);
-			String shortUrl = data.optString("url_short");
-			if (!StringUtil.isNullOrEmpty(shortUrl))
-				return shortUrl;
+			JSONObject data = JSONArray.fromObject(result).optJSONObject(0);
+			return data.optString("url_short");
 		} catch (Exception e) {
 			e.printStackTrace();
 		}
@@ -94,15 +90,11 @@
 	private static String getShortLink3(String url) {
 		try {
 			String totalUrl = String.format(
-					"https://api.weibo.com/2/short_url/shorten.json?source=2963429064&url_long=%s",
+					"http://api.t.sina.com.cn/short_url/shorten.json?source=2963429064&url_long=%s",
 					URLEncoder.encode(url));
 			String result = get(totalUrl, null);
-			JSONObject data = JSONObject.fromObject(result);
-			JSONArray array = data.optJSONArray("urls");
-			data = array.optJSONObject(0);
-			String shortUrl = data.optString("url_short");
-			if (!StringUtil.isNullOrEmpty(shortUrl))
-				return shortUrl;
+			JSONObject data = JSONArray.fromObject(result).optJSONObject(0);
+			return data.optString("url_short");
 		} catch (Exception e) {
 			e.printStackTrace();
 		}
@@ -321,7 +313,6 @@
 		return null;
 	}
 
-	
 	public static String postSimple(String url) {
 		HttpClient client = new HttpClient();
 		PostMethod method = new PostMethod(url);
@@ -335,8 +326,7 @@
 		}
 		return "";
 	}
-	
-	
+
 	public static String post(String url) {
 		HttpClient client = new HttpClient();
 		PostMethod method = new PostMethod(url);
@@ -413,7 +403,7 @@
 
 	public static String post(String url, Map<String, String> map, Map<String, String> headers) {
 		HttpClient client = new HttpClient();
-//		 client.getHostConfiguration().setProxy("192.168.1.122", 8888);
+		// client.getHostConfiguration().setProxy("192.168.1.122", 8888);
 		PostMethod pm = new PostMethod(url);// 鍒涘缓HttpPost瀵硅薄
 		NameValuePair[] ns = new NameValuePair[map.keySet().size()];
 		Iterator<String> its = map.keySet().iterator();

--
Gitblit v1.8.0