我試圖從imgur網站獲取xml文件中的圖像。從imgur爲android獲取圖像的xml文件
這是我寫的代碼:
try {
HttpClient client = new DefaultHttpClient();
String getURL = "http://api.imgur.com/2/account/images.xml";
HttpGet get = new HttpGet(getURL);
HttpResponse responseGet = client.execute(get);
HttpEntity mResEntityGet = responseGet.getEntity();
if (mResEntityGet != null) {
//do something with the response
String content = EntityUtils.toString(mResEntityGet);
}
} catch (ClientProtocolException e) {}
} catch (IOException e) {}
的問題是,該行 「的HttpResponse responseGet = client.execute(獲得);」拋出IOexception。
如果我寫在瀏覽器中的網址,然後它給了我下面的XML:
<?xml version="1.0" encoding="utf-8" ?>
- <error>
<message>This method requires authentication</message>
<request>/2/account/images.xml</request>
<method>get</method>
<format>xml</format>
<parameters />
</error>
任何想法,我怎樣才能從imgur網站上的圖像的xml文件?
鏈接無效 – AndroidOptimist