0

我现在正在努力使用 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'>"));

但无济于事。如果有人可以提供帮助,将不胜感激。谢谢!

4

1 回答 1

2

值标题和数组播放器位于查询视频博客帖子的响应中。不是添加新视频帖子的参数。该部分:tumblr.com/docs/en/api/v2#posting 包含您要使用的参数:标题、嵌入、数据(所有字符串...)

于 2013-03-18T20:33:01.230 回答