Rand Stats

WebService::Lastfm

github:avuserow

NAME

WebService::Lastfm - interact with Last.fm's API

SYNOPSIS

my $lastfm = WebService::Lastfm.new(:api-key<1234>, :api-secret<music>);

# Read request
say $lastfm.request('user.getInfo', :user<avuserow>);

# Update now playing
say $lastfm.write('track.updateNowPlaying',
    :sk<SECRET KEY>,
    :artist("Alan Parsons Project"),
    :track<Time>,
    :duration<360>,
);

DESCRIPTION

Bindings for Last.fm's API using the JSON format (instead of their default XML). You must register for their API to get an API key and API secret.

METHODS

new($api-key, $api-secret)

Standard new method. All parameters are optional, but the API key is needed for all known requests, and the secret is needed for write methods.

request($method, *%params)

Make an unsigned GET request, used for read-only operations.

write($method, *%params)

Make a signed POST request, used for writing operations, the most famous of which is "scrobbling" (track.scrobble).

EXCEPTIONS

X::WebService::Lastfm is thrown on any error responses, with the decoded error message from Last.fm. Check the method's documentation (or the API documentation overall) for the meaning of the code.

CAVEATS

TODO

REQUIREMENTS

SEE ALSO

Last.fm's API documentation