Tumblr v2 API 访问私人博客

4

我曾经费尽心思搜索,但是无法找到相关答案。 我想知道是否有人遇到过Tumblr API v2调用,可以让您访问私有博客的数据。 当然,我想要在提供身份验证的情况下发布和检索列表来自我的一些私人博客。

谢谢


很遗憾,这是不可能的。获取此类信息的最佳来源是Tumblr API用户组,如果您在那里提问,至少有机会让Tumblr的开发人员看到它 :) - Philipp Schlösser
谢谢您的回复,根据tumblr的说法,您是正确的。我会查看用户组,谢谢。 - four2theizz0
2个回答

5

通过正确的OAuth调用API,并使用私人博客的访问令牌,可以使用Tumblr API v2访问至少一些私人博客的信息。

以下是我的一些观察:

  • api.tumblr.com/v2/blog/{base-hostname}/posts

    Normally you make this call with your Public API Key, and that allows you to access the posts of any Tumblr that is not private.

    However! Good news: If you include the full OAuth headers when making this request, it will return the list of posts of a Private Tumblr account. You need an access Token for that Tumblr, of course, to do this. Yes, I have tried this, done this, and it works.

    If you only use your consumer API key, e.g.

    api.tumblr.com/v2/blog/{base-hostname}/posts?api_key=w8878374r384r...
    

    Then you will get nothing. You have to make a fully-authenticated request with all of the proper OAuth parameters.

  • api.tumblr.com/v2/blog/{base-hostname}/info

    Will not work at all for a private blog, even when using all the proper OAuth stuff to make the API call.

  • api.tumblr.com/v2/user/info

    Normally this returns a list of "blogs" for the given authenticated user. However, any private tumblrs will not show up in this list of blogs.

注意:

  • 我还没有测试许多私有博客的其他API调用,所以我不能确定创建/编辑/删除文章是否有效。

  • 我尚未使用xAuth进行测试,只使用过常规OAuth和通过“Web授权流程”获得的标准访问令牌。


嘿Felix, 感谢你提供详细的发现。我将尝试使用Oauth路线,并一直怀疑这可能有效。我会回报并接受。 谢谢! - four2theizz0

-1
$conskey = "CONSUMER KEY";
$conssec = "CONSUMER SECRET";

$tumblr_blog = "myblog.tumblr.com";
$to_be_posted = "This is the text to be posted";

$oauth = new OAuth($conskey,$conssec);
$oauth->fetch("http://api.tumblr.com/v2/blog/".$tumblr_blog."/post", array('type'=>'text', 'body'=>$to_be_posted), OAUTH_HTTP_METHOD_POST);

$result = json_decode($oauth->getLastResponse());

if($result->meta->status == 200){
  echo 'Success!';
}

尝试使用API上面的代码来发布博客。

希望能有所帮助。


我在哪里可以获取oAuth类$oauth = new OAuth($conskey,$conssec); - t q
1
oAuth可以安装在您的服务器上。它还必须在您的php.ini中启用。请参阅此链接-->http://php.net/manual/en/book.oauth.php - Eralph

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接