私はimgurのウェブサイトから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(get);」です。IOexceptionをスローします。
エクスプローラーでURLを書き込むと、次の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ファイルを取得するにはどうすればよいですか?