| | |
| | | import java.net.MalformedURLException;
|
| | | import java.net.URL;
|
| | | import java.net.URLEncoder;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Iterator;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | |
|
| | | import org.apache.commons.httpclient.Header;
|
| | |
| | | import org.apache.http.auth.UsernamePasswordCredentials;
|
| | | import org.apache.http.client.CredentialsProvider;
|
| | | import org.apache.http.client.config.RequestConfig;
|
| | | import org.apache.http.client.entity.UrlEncodedFormEntity;
|
| | | import org.apache.http.client.methods.CloseableHttpResponse;
|
| | | import org.apache.http.client.methods.HttpPost;
|
| | | import org.apache.http.impl.client.BasicCredentialsProvider;
|
| | |
| | |
|
| | | import net.sf.json.JSONArray;
|
| | | import net.sf.json.JSONObject;
|
| | | import sun.rmi.log.LogHandler;
|
| | |
|
| | | public class HttpUtil {
|
| | |
|
| | |
| | | return "";
|
| | | }
|
| | |
|
| | | public static String getShortLink(String url) {
|
| | | public static String getShortLink(String url) { |
| | | String shortLink = getShortLink2(url);
|
| | | if (StringUtil.isNullOrEmpty(shortLink))
|
| | | shortLink = getShortLink3(url);
|
| | |
| | | return null;
|
| | | }
|
| | |
|
| | | |
| | | public static String postSimple(String url) {
|
| | | HttpClient client = new HttpClient();
|
| | | PostMethod method = new PostMethod(url);
|
| | | try {
|
| | | client.executeMethod(method);
|
| | | return method.getResponseBodyAsString();
|
| | | } catch (HttpException e) {
|
| | | e.printStackTrace();
|
| | | } catch (IOException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | return "";
|
| | | }
|
| | | |
| | | |
| | | public static String post(String url) {
|
| | | HttpClient client = new HttpClient();
|
| | | PostMethod method = new PostMethod(url);
|