Search code examples
androidxmlimagegetimgur

getting images in xml file from imgur for android


I am trying to get the images in xml file from the imgur website.

This is the code I have written:

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) {}

The problem is that the row "HttpResponse responseGet = client.execute(get);" throws IOexception.

If I write the url in the explorer then it gives me the following 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>

Any idea how can I get the xml file with the images from the imgur website?


Solution

  • I thought you need to provide login details see http://api.imgur.com/auth