我试图在 ANDROID 上使用以下代码从缩短的 URL 中获取 URL。所以如果你有任何想法请帮助我~~
有很多关于“ response.getHeaders("Location")
; will work~”的评论,但我不认为getHeaders("Location")会工作
有没有其他方法可以获取长 URL...?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~
HttpClient myclient = new DefaultHttpClient();
String url = "http://goo.gl/XNK93Q";
HttpGet myget = new HttpGet(url);
HttpResponse response = null;
response = myclient.execute(myget);
HttpEntity entity = response.getEntity();
for(Header header : response.getHeaders("Location")) {
System.out.println("Location from connect:" + header.getValue());
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~