2011-11-14 15 views
0
HttpClient httpclient = new DefaultHttpClient(); 
      HttpPost post = new HttpPost(
        "http://api.flickr.com/services/upload/"); 
      HttpResponse response; 
      try { 
       response = httpclient.execute(post); 
       HttpEntity entity = response.getEntity(); 
       if (entity != null) { 
        InputStream inputstream = entity.getContent(); 
        BufferedReader bufferedreader = new BufferedReader(
          new InputStreamReader(inputstream)); 
        StringBuilder stringbuilder = new StringBuilder(); 
        String currentline = null; 
        try { 
         while ((currentline = bufferedreader.readLine()) != null) { 
          stringbuilder.append(currentline + "\n"); 
         } 
        } catch (IOException e) { 
         e.printStackTrace(); 
        } 
        String result = stringbuilder.toString(); 
        System.out.println(result); 
       } 

       // HttpPost hp = new HttpPost(fma.upload_url); 
       try { 
        Bitmap bm = BitmapFactory.decodeFile(file.toString() 
          + "/09102011079.jpg"); 
        ByteArrayOutputStream baos = new ByteArrayOutputStream(); 
        bm.compress(Bitmap.CompressFormat.JPEG, 50, baos); 
        byte[] b = baos.toByteArray(); 
        ByteArrayBody bab = new ByteArrayBody(b, ""); 
        MultipartEntity me = new MultipartEntity(); 
        me.addPart("media", bab); 
        post.setEntity(me); 
        /*String s = "<root>" + "<entities>" + "<media>" 
          + "<size>" + "<large>" + "<width>700</width>" 
          + "<height>500<height>" 
          + "<resize>\"fit\"</resize>" + "</large>" 
          + "</size>" + "</media>" + "</entities>" 
          + "</root>";*/ 
        /* 
        * try { se = new StringEntity(s); } catch 
        * (UnsupportedEncodingException e1) { // TODO // 
        * Auto-generated // catch // block // 
        * e1.printStackTrace(); // } // } 
        */ 
        // ByteArrayEntity bae = new ByteArrayEntity(b); // 
        // hp.setEntity(se); // hp.setEntity(bae); 
        fma.consumer.sign(post); 
        DefaultHttpClient client = new DefaultHttpClient(); 
        client.execute(post); 
       } catch (OAuthMessageSignerException e) { 
        System.out.println(e.getMessage()); 
       } catch (OAuthExpectationFailedException e) { 
        System.out.println(e.getMessage()); 
       } catch (OAuthCommunicationException e) { 
        System.out.println(e.getMessage()); 
       } catch (ClientProtocolException e) { 
        System.out.println(e.getMessage()); 
       } catch (IOException e) { 
        System.out.println(e.getMessage()); 
       } 

      } catch (Exception e) { 

      } 

は、これは私のアップロードのコードが、私はこのエラー------>FlickrのREST APIの(写真のアップロードは)

11-14 12を取得していますたびにあるINFO /無効なAPIキー(無効な形式のキーです) "

私を助けてください。//System.out(444):
err code =" 100 "前もって感謝します。

答えて

3

あなたはFlickr upload API

100を見てみた場合:無効なAPIキー: を通過したAPIキーが有効ではありませんでしたか、期限が切れています。

あなたのAPIキーが間違っていたと思います。 Flickr APIを使用するには、アプリケーションキーが必要です。

現在のところ、APIの商用利用は事前の許可がある場合にのみ許可されています。商用利用を目的としたAPIキーのリクエストは、スタッフが確認します。ここで

how to get an API key


ある写真はありません必要な引数が欠落して 写真を指定しました。

+0

エラーコード2と呼ばれる別のコードが修正されました – Rocker

+0

写真の引数を指定する方法を教えてください... – Rocker

+0

成功すればコードを共有できますか? –

関連する問題