android – Jumblr API在向Tumblr发布图像时提供了错误的请求

是)我有的

我有一个图像文件对象试图使用Jumblr API发布到Tumblr

我的问题

当我尝试发布图像时,我得到com.tumblr.jumblr.exceptions.JumblrException:错误的请求响应代码:400

我的代码

client = new JumblrClient(CONSUMER_KEY,SECRET_KEY);
                            client.setToken(TOKEN, TOKEN_SECRET);
                            User user=client.user();
                            userName=user.getName();

                            PhotoPost photoPost=client.newPost(client.user().getBlogs().get(0).getName(),PhotoPost.class);
                            photoPost.setCaption("My Tumblr post");


                            photoPost.setPhoto(new Photo(Methods.FILE_IMAGE));
                            photoPost.save();

最佳答案 我使用Jumblr遇到了同样的问题.

而不是这个方法(它以某种方式触发Android画廊?无法找到Methods.FILE_IMAGE的任何javadoc)

photoPost.setPhoto(new Photo(Methods.FILE_IMAGE));

我建议你试试任何味道

photoPost.setData(new File(fileName)); //if it's possible on Android

请尝试使用不同的文件:Tumblr不仅有文件大小限制,还有一些奇怪的检查文件是否有效.我上传的~3%的gif文件丢弃请求响应代码:400.这些文件不超过GIF大小限制并且它们在我的机器上显示正常,但是Tumblr由于某种原因拒绝它们,所以请尝试使用post.setData并使用一些防弹有效文件进行尝试,因为其余的代码 – 看起来你肯定做得对

点赞