0

私は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ファイルを取得するにはどうすればよいですか?

4

2 に答える 2

2

ログインの詳細を提供する必要があると思いましたhttp://api.imgur.com/authを参照してください

于 2011-07-04T08:58:00.150 に答える