NAME
Net::LastFMAPI - LastFM API 2.0
SYNOPSIS
use Net::LastFMAPI;
my $xml = lastfm("artist.getSimilar", artist => "Robbie Basho");
$Net::LastFMAPI::json = 1;
my $data = lastfm(...); # decodes it for you
# sets up a session/gets authorisation when needed for write actions:
my $res = lastfm(
"track.scrobble",
artist => "Robbie Basho",
track => "Wounded Knee Soliloquy",
timestamp => time(),
);
$success = $res =~ m{<scrobbles accepted="1"};
DESCRIPTION
Makes requests to http://ws.audioscrobbler.com/2.0/ and returns the result.
Takes care of POSTing to write methods, doing authorisation when needed.
Dies if something went obviously wrong.
THE SESSION KEY
$Net::LastFMAPI::session_key = "secret"
It will be sought when an authorised request is needed.
If it is not saved then on-screen instructions should be followed to authorise with whoever is logged in to last.fm.
It is saved in the symlink $ENV{HOME}/.net-lastfmapi-sessionkey. This is probably fine.
Consider altering the subroutines talk_authentication, load_save_sessionkey, or simply setting the $Net::LastFMAPI::session_key before needing it.
RETURN PERL DATA
$Net::LastFMAPI::json = 1
This will automatically add format => "json" to every request and decode the result into perl data for you.
Not all methods support JSON. Beware of "@attr" and empty elements turned into whitespace strings instead of empty arrays.
CACHING
$Net::LastFMAPI::cache = 1
$Net::LastFMAPI::cache_dir = "$ENV{HOME}/.net-lastfmapi-cache/"
Does caching. Default cache directory is shown. Good for development.
SEE ALSO
Net::LastFM doesn't handle sessions for you, won't POST to write methods
I had no luck with the 1.2 API modules: WebService::LastFM, Music::Audioscrobbler::Submit, Net::LastFM::Submission
BUGS/CODE
https://github.com/st3vil/Net-LastFMAPI
AUTHOR
Steev Eeeriumn <drsteve@cpan.org>
COPYRIGHT
Copyright (c) 2011, Steev Eeeriumn. All Rights Reserved.
This module is free software. It may be used, redistributed
and/or modified under the terms of the Perl Artistic License
(see http://www.perl.com/perl/misc/Artistic.html)