public static DefaultHttpClient httpclient; static { httpclient = new DefaultHttpClient(); // httpclient = (DefaultHttpClient) HttpClientConnectionManager.getSSLInstance(httpclient); } public static void main(String []args){ try { HttpPost httpost = new HttpPost("http://dwz.cn/create.php"); List<NameValuePair> params = new ArrayList<NameValuePair>(); params.add(new BasicNameValuePair("url", "https://www.hxyxt.com")); // 用户名称 httpost.setEntity(new UrlEncodedFormEntity(params, "utf-8")); HttpResponse response = httpclient.execute(httpost); String jsonStr = EntityUtils.toString(response.getEntity(), "utf-8"); String tinyurl = jsonStr.replace("{\"tinyurl\":\"", ""); int index = tinyurl.indexOf("\",\"status"); tinyurl = tinyurl.substring(0,index).replace("\\/", "/"); System.out.println(tinyurl); } catch (Exception e) { e.printStackTrace(); } }
JAVA使用百度短网址
最新推荐文章于 2023-10-07 09:33:14 发布