four2theizz0
four2theizz0

Reputation: 51

Tumblr v2 API accessing private blogs

Have been searching high and low and cannot find any relevant answer on this. I was wondering if anyone has come across the Tumblr API v2 call that will let you access data from a private blog. I would like to post and retrieve listings from some of my private blogs while providing authentication of course.

Thank you

Upvotes: 4

Views: 25029

Answers (2)

Eralph
Eralph

Reputation: 954

$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!';
}

Try the code above to post to your blog using API.

Hope that helps.

Upvotes: -1

Felix
Felix

Reputation: 541

Using correct OAuth calls to the API, with an access Token for a private blog, it is possible to access at least some of that private blog's information with the Tumblr API v2.

Here are some observations I have made:

  • 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.

Note:

  • I have not tested many of the other API calls with private blogs, so I cannot tell you for sure if creating/editing/removing posts works or not.

  • I have not tested this at all with xAuth, only regular OAuth and a standard access Token obtained through the "web authorization flow"

Upvotes: 5

Related Questions