0

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?

4

2 回答 2

2

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

于 2011-07-04T08:58:00.150 回答
-1

For Imgur.com > Subreddits Image Xml

https://imgur.com/r/{SUBREDDIT ID}/page/0.xml

For Imgur.com > Albums Image Xml

https://api.imgur.com/2/album/{ALBUM ID}

于 2015-07-02T14:59:17.903 回答