百度短网址服务

    百度短网址服务api文档

                                String shareUrl = "http://www.baidu.com/";

RestTemplate template = new RestTemplate();

//百度短地址服务

String url = "http://dwz.cn/create.php";

LinkedMultiValueMap<String, Object> parts = new LinkedMultiValueMap<String, Object>();

parts.add("url", shareUrl);

String result = template

.postForObject(url, parts, String.class);

JSONObject jsonObject = JSONObject.fromString(result);

if (jsonObject.getInt("status") == 0

&& jsonObject.containsKey("tinyurl")) {

shareUrl = jsonObject.getString("tinyurl");

}


你可能感兴趣的:(百度、短网址、java)