2013-07-11 92 views
0
{"meta":{"status":401,"msg":"Not Authorized"},"response":[]} 

Tumblr在張貼圖片時給出了上述結果。使用tumblr發佈圖片

DefaultHttpClient client = new DefaultHttpClient(); 
HttpResponse resp = null; 
String result = null; 
HttpPost hpost = new HttpPost("http://api.tumblr.com/v2/blog/" + username    
                 +".tumblr.com/post"); 
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2); 
nameValuePairs.add(new BasicNameValuePair("type", "photo")); 
nameValuePairs.add(new BasicNameValuePair("caption", "hello")); 
nameValuePairs.add(new BasicNameValuePair("source", "url_of_the_image")); 


     String debug = ""; 
     try { 
      hpost.setEntity(new UrlEncodedFormEntity(
        nameValuePairs)); 
      consumer.sign(hpost); 
      resp = client.execute(hpost); 
      result = EntityUtils.toString(resp.getEntity()); 
      Log.v("result >>", result); 
     } catch (UnsupportedEncodingException e) { 
      debug += e.toString(); 
     } catch (OAuthMessageSignerException e) { 
      // TODO Auto-generated catch block 
      e.printStackTrace(); 
     } catch (OAuthExpectationFailedException e) { 
      // TODO Auto-generated catch block 
      e.printStackTrace(); 
     } catch (OAuthCommunicationException e) { 
      // TODO Auto-generated catch block 
      e.printStackTrace(); 
     } catch (ClientProtocolException e) { 
      // TODO Auto-generated catch block 
      e.printStackTrace(); 
     } catch (IOException e) { 
      // TODO Auto-generated catch block 
      e.printStackTrace(); 
     } 

我需要發佈圖像在tumblr。給我一些解決方案。

回答