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('pepito@chistes.com'); $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 read, read_json and 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.
read
read_json
write
The Tumblr API is not really long or difficult and this implementation covers it fully.
Because I can! And because I wanted to use a sane OO way to implement Blog::Normalize::Tumblr without just scrapping, which is what I did, heh.
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 );
If $email is specified, it sets the email class variable, otherwise, the previous value is returned. This is the email that users use to log in to Tumblr.
$email
password( $password );
If $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.
$password
user( $user );
If $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).
$user
url( $url );
If $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).
$url
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( # 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.
write( type => $type, ... # other write args );
Posts a type item with the needed arguments from the Tumblr API. The type argument is mandatory. email and 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 data argument.
type
email
password
data
check_audio();
Checks if the user can upload an audio file. Returns true or undef.
check_vimeo();
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.
authenticate();
Checks if the email and password specified are correct. If they are, it returns true, otherwise, undef.
errstr();
It returns the error string for the last operation, so you can see why other methods failed.
_POST_request($string);
Internal method to post $string to Tumblr. You shouldn't be using it anyway.
$string
http://tumblr.com, http://tumblr.com/api. See also the sample scripts on the examples/ dir.
David Moreno Garza, <david@axiombox.com>
You know who (http://maggit.net).
Copyright (C) 2008 by David Moreno Garza - Axiombox
http://axiombox.com
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.
To install WWW::Tumblr, copy and paste the appropriate command in to your terminal.
cpanm
cpanm WWW::Tumblr
CPAN shell
perl -MCPAN -e shell install WWW::Tumblr
For more information on module installation, please visit the detailed CPAN module installation guide.