| | |
| | |
|
| | | private static String getShortLink1(String url) {
|
| | | try {
|
| | | String totalUrl = String.format("http://api.suolink.cn/api.php?url=%s", URLEncoder.encode(url));
|
| | | String totalUrl = String.format(
|
| | | "http://suo.im/api.htm?format=json&url=%s&key=5d7728078e676d45275f816b@681bb0446f1e6af4f8fc6ce3cad2a684",
|
| | | URLEncoder.encode(url));
|
| | | String result = get(totalUrl, null);
|
| | | if (!StringUtil.isNullOrEmpty(result) && result.startsWith("http"))
|
| | | return result.trim();
|
| | | System.out.println(result);
|
| | | try {
|
| | | JSONObject json = JSONObject.fromObject(result);
|
| | | return json.optString("url");
|
| | | } catch (Exception e) {
|
| | | }
|
| | | } catch (Exception e) {
|
| | | return url;
|
| | | }
|
| | | return null;
|
| | | }
|
| | |
| | | private static String getShortLink2(String url) {
|
| | | try {
|
| | | String totalUrl = String.format(
|
| | | "http://api.t.sina.com.cn/short_url/shorten.json?source=3403499693&url_long=%s",
|
| | | "http://api.t.sina.com.cn/short_url/shorten.json?source=2849184197&url_long=%s", // 3403499693
|
| | | URLEncoder.encode(url));
|
| | | String result = get(totalUrl, null);
|
| | | System.out.println(result);
|
| | | JSONObject data = JSONArray.fromObject(result).optJSONObject(0);
|
| | | return data.optString("url_short");
|
| | | } catch (Exception e) {
|