Jumblr API提供了错误的请求而发布图像的tumblr [英] Jumblr API gives bad request while posting image to Tumblr

查看:826
本文介绍了Jumblr API提供了错误的请求而发布图像的tumblr的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有什么

我有一个图像文件对象尝试使用张贴到的tumblr Jumblr API

我的问题

当我尝试后,我得到 com.tumblr.jumblr.exceptions.JumblrException形象:错误的请求响应code:400

我的code

 客户端=新JumblrClient(CONSUMER_KEY,SECRET_KEY);
                            client.setToken(TOKEN,TOKEN_SECRET);
                            用户的用户= client.user();
                            的userName = user.getName();                            PhotoPost photoPost = client.newPost(client.user()getBlogs()获得(0).getName(),PhotoPost.class);
                            photoPost.setCaption(我的Tumblr邮报);
                            photoPost.setPhoto(新照片(Methods.FILE_IMAGE));
                            photoPost.save();


解决方案

我遇到使用Jumblr同样的问题。

相反,这种方法(它在某种程度上触发Android的画廊?找不到任何Methods.FILE_IMAGE的javadoc)的

  photoPost.setPhoto(新照片(Methods.FILE_IMAGE));

我建议你去尝试任何味道

  photoPost.setData(新文件(文件名)); //是否有可能在Android上

和请及时与不同的文件试试吧:的tumblr不仅文件大小限制,而且对文件是有效的一些奇怪的检查。 〜GIF文件3%,我上传扔的错误的请求响应code:400 。这些文件不超过GIF大小限制和他们显示我的机器上很好,但的tumblr,出于某种原因拒绝他们,所以请尽量post.setData并与一些防弹有效的文件试试吧,因为从$其余C $ç - 它肯定看起来像你这样做是正确的。

What I have

I have an image File object trying to post to Tumblr using Jumblr API

My problem

When I try to post the image I get com.tumblr.jumblr.exceptions.JumblrException: Bad Request Response code :400

My code

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();

解决方案

I've encountered the same issue using Jumblr.

Instead of this method (does it somehow trigger Android gallery? Couldn't find any javadoc for Methods.FILE_IMAGE)

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

I suggest you to try any flavor of

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

And please try it with different files: Tumblr has not only file-size limitations, but also some weird check for file being valid. ~3% of gif files I upload throw Bad Request Response code :400. Those files are not exceeding GIF size limit and they're displayed fine on my machine, but Tumblr, for some reason rejects them, so please try post.setData and try it with some bulletproof-valid file, because from the rest of your code - it definitely looks like you're doing it right

这篇关于Jumblr API提供了错误的请求而发布图像的tumblr的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆