0
 {"meta":{"status":401,"msg":"Not Authorized"},"response":[]}

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 中发布图像。给我一些解决方案。

4

1 回答 1

0

您是否考虑过使用第三方库?Temboo SDK(需要免费帐户)包括通过传递照片 URL 或照片的 Base64 编码内容来创建 Tumblr 照片帖子的方法。看一眼:

https://www.temboo.com/library/Library/Tumblr/Post/CreatePhotoPostWithURL/ https://www.temboo.com/library/Library/Tumblr/Post/CreatePhotoPostWithImageFile/

全面披露——我在 Temboo 工作。

于 2013-07-12T14:58:51.990 回答