我现在正在努力使用 Tumblr api。 当我仅发布文本时,这非常简单,因为我只需要提供字符串标题和字符串正文。 引用api文档( http://www.tumblr.com/docs/en/api/v2#text-posts ),我使用了以下代码并且成功运行。
HttpPost hpost = new HttpPost(BASE_URL + "/blog/" + blog + ".tumblr.com/post");
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
nameValuePairs.add(new BasicNameValuePair("type", "text"));
nameValuePairs.add(new BasicNameValuePair("text", title));
nameValuePairs.add(new BasicNameValuePair("body", body));
hpost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
consumer.sign(hpost);
DefaultHttpClient client = new DefaultHttpClient();
HttpResponse resp = null;
resp = client.execute(hpost);
但是,问题是当我发布视频时,我必须提供字符串标题和数组播放器。 (http://www.tumblr.com/docs/en/api/v2#video-posts) 我的问题是,如何将嵌入代码传递给 NameValuePair 对象? 我只需要发布一个视频,因此数组的大小将为 1。 我尝试了以下代码:
HttpPost hpost = new HttpPost(BASE_URL + "/blog/" + blog + ".tumblr.com/post");
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
nameValuePairs.add(new BasicNameValuePair("type", "video"));
nameValuePairs.add(new BasicNameValuePair("caption", title));
nameValuePairs.add(new BasicNameValuePair("player", "<embed src='blah'>"));
但无济于事。 如果有人可以提供帮助,那将非常感激。谢谢!
最佳答案
标题和数组播放器的值位于查询视频博客帖子的响应中。不是添加新视频帖子的参数。该部分:tumblr.com/docs/en/api/v2#posting 包含您要使用的参数:标题、嵌入、数据(所有字符串...)
关于java - 使用 Java 中的 Tumblr API 发布视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15485974/