用户工具

站点工具


分享:技术:微博:新浪短网址集成

这是本文档旧的修订版!


新浪短网址集成

准备

登录新浪微博开发整账号:cinvestors\_app@tebon.com.cn,选择审核过的应用,查看[应用信息-基本信息]下的App Key,用于下面接口调用

调API

String APP_KEY = "1570065866";//APP KEY
String targetUrl = "http://www.cinvestors.com.cn/opmt-web/";//原始URL
String sinaApiUrl = "http://api.t.sina.com.cn/short_url/shorten.json?source=" + APP_KEY + "&url_long=" + targetUrl;//SINA API URL
String jsonStr = HttpClientUtils.getWebContentByGet(sinaApiUrl);//调用API
System.out.println(jsonStr);//输出JSON串

输出

结果中的url\_short即为新浪短网址

[{"url_short":"http://t.cn/RGKJv9Y","url_long":"http://www.cinvestors.com.cn/opmt-web/","type":0}]

验证

分享/技术/微博/新浪短网址集成.1459307290.txt.gz · 最后更改: 2016/03/30 11:08 由 gxx