WWW::Tumblr - Perl interface for the Tumblr API
use WWW::Tumblr; # read method my $t = WWW::Tumblr->new; # Will read http://juanito.tumblr.com/api/read $t->user('juanito'); # Will read http://log.damog.net/api/read $t->url('http://log.damog.net'); # Pass Tumblr API read arguments to the read() method $t->read( start => 2, num => 10, ... ); # Will get you JSON back # Same arguments as read, as defined by the API $t->read_json( ... ); # write # Object initialization my $t = WWW::Tumblr->new; # The email you use to log in to Tumblr $t->email('firstname.lastname@example.org'); $t->password('foobar'); # You will always have to pass a type to write() and the additional # args depend on that type and the requests by the Tumblr API $t->write( type => 'regular', body => 'My body text', ... type => 'quote', quote => 'I once had a girlfriend...', ... type => 'conversation', title => 'On the subway...', conversation => 'Meh, meh, meh.', ... # File uploads: type => 'audio', data => '/tmp/my.mp3', ... ); # other actions $t->authenticate or die $t->errstr; $t->check_audio or die $t->errstr; my $vimeo = $t->check_vimeo or die $t->errstr;
All options passed to
write are all of the parameters specified on http://www.tumblr.com/api and you simple have to pass them as key => values argument pairs.
The Tumblr API is not really long or difficult and this implementation covers it fully.
new( user => $user, email => $email, password => $password, url => $url, );
Initilizes a class instance.
All arguments are optional, you can specify most of them here on each of the method calls anyway.
email( $email );
password( $password );
$password is specified, it sets the password class variable, otherwise the previous value is returned. This is the password used by users to log in to Tumblr.
user( $user );
$user is specified, it sets the user class variable, otherwise the previous value is returned. This is the user portion of the tumblr.com URL (ie. maria.tumblr.com).
url( $url );
$url is specified, it sets the url class variable. Otherwise, the previous value is returned. This is the URL that some people might use for their Tumblelogs instead of user.tumblr.com (in my case, http://log.damog.net).
read_json( # read params ... );
Returns the JSON version of c<read>, it accepts the same Tumblr API arguments. It returns the JSON version of
read( # read args ... );
You should have specified the user or url to use this method. Parameters to be passed are the ones specified on the Tumblr API, such as id, num, type, etc. It returns an XML string containing the output.
If the option
auth => 1 is passed, an authenticated read request is being made in order to retrieve the private posts as well. See Tumblr's API for details.
write( type => $type, ... # other write args );
type item with the needed arguments from the Tumblr API. The
type argument is mandatory.
password should have been specified before too. In success, it returns true, otherwise, it returns undef. For file uploads, just specify the filename on the
edit( 'post-id' => 123, type => 'regular', title => 'This has changed!', ... );
Edits the post idenfied with
post-id. The same parameters as those used with
write can be used, but
post-id has to be specified.
delete( 'post-id' => 123, );
Deletes the post idenfied with the
This method has been deprecated on this implementation since it was also on the Tumblr API.
Checks if the user can upload an audio file. Returns true or undef.
Deprecated as the Tumblr API discontinued it.
Checks if the user is logged in on Vimeo, as specified by the Tumblr API. Returns the maximum number of bytes available for the user to upload in case the user is logged in, otherwise it returns undef.
Checks if the
password specified are correct. If they are, it returns true, otherwise, undef.
It returns the error string for the last operation, so you can see why other methods failed.
Internal method to post
$string to Tumblr. You shouldn't be using it anyway.
This and other interesting modules and hacks are posted by the author on his blog Infinite Pig Theorem, http://damog.net.
The code is actively maintained at http://github.com/damog/www-tumblr.
David Moreno Garza, <email@example.com>
You know who (http://maggit.net).
Copyright (C) 2008 by David Moreno Garza - Axiombox
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.
I'm not a worker nor affiliated to Tumblr in any way, and this is a separated implementation of their own public API.