NAME
WWW::AfinimaKi - AfinimaKi Recommendation Engine Client
SYNOPSIS
use WWW::AfinimaKi; # Notice the uppercase "K"!
my $api = WWW::AfinimaKi->new( $your_api_key, $your_api_secret);
...
$api->set_rate($user_id, $item_id, $rate);
...
my $estimated_rate = $api->estimate_rate($user_id, $rate);
...
my $recommendations = $api->get_recommendations($user_id);
foreach (@$recommendations) {
print "item_id: $_->{item_id} estimated_rate: $_->{estimated_rate}\n";
}
DESCRIPTION
WWW::AfinimaKi is a simple client for the AfinimaKi Recommendation API. Check http://www.afinimaki.com for more details.
Methods
new
my $api = WWW::AfinimaKi->new(
api_key => $your_api_key,
api_secret => $your_api_secret,
debug => $debug_level,
);
if (!$api) {
die "Error construction afinimaki, wrong keys length?";
}
new Construct the AfinimaKi object. No network traffic is
generated (the account credentialas are not checked at this point).
The given keys must be 32 character long. You can get them at
www.afinimaki.com
Debug level can be 0 or 1.
user-item services
set_rate_, add_to_wishlist, add_to_blacklist, remove_from_lists
$api->set_rate($user_id, $item_id, $rate);
$api->set_rate($user_id, $item_id, $rate, $ts);
$api->add_to_wishlist($user_id, $item_id);
$api->add_to_wishlist($user_id, $item_id, $ts);
$api->add_to_blacklist($user_id, $item_id);
$api->add_to_blacklist($user_id, $item_id, $ts);
$api->remove_from_lists($user_id, $item_id);
All calls wait until the call has ended.
$ts is the unix timestamp when the action was done
(if $ts is not given, the action was performed now).
On error, return is undef, and the RPC::XML error will be carp'ed.
On success, the returned values are:
1: The rate was inserted
2: The rate existed previous, and it was NOT modified
3: The rate existed previous, and it was updated by
this call
set_rate
Stores a rate in the server
add_to_wishlist
Adds the given $item_id to user's wishlist. This
means that id will not be in the user's recommentation
list, and the action will be use to tune users's
recommendations (The user seems to like this item).
add_to_blacklist
Adds the given $item_id to user's blacklist. This
means that id will not be in the user's recommentation
list, and the action will be use to tune users's
recommendations (The user seems to dislike this item).
remove_from_lists Stores a rate in the server.
Removes the given item from user's wish and black lists,
and also removes user item's rating (if any).
estimate_rate
my $estimated_rate = $api->estimate_rate($user_id, $item_id);
Estimate a rate. Undef is returned if the rate could not
be estimated (usually because the given user or the given
item does not have many rates).
On error, returns undef, and carp the RPC::XML error.
estimate_multiple_rates
my $rates_hashref = $api->estimate_rate($user_id, @item_ids);
foreach my $item_id (keys %$rates_hashref) {
print "Estimated rate for $item_id is
$rates_hashref->{$item_id}\n";
}
Estimate multimple rates. The returned hash has
the structure:
item_id => estimated_rate
On error, returns undef, and carp the RPC::XML error.
get_recommendations
my $recommendations = $api->get_recommendations($user_id);
foreach (@$recommendations) {
print "item_id: $_->{item_id}
estimated_rate: $_->{estimated_rate}\n";
}
Get a list of user's recommentations, based on users'
and community previous rates. Recommendations does not
include rated or marked items (in the whish or black list).
user-user services
get_user_user_afinimaki
my $afinimaki =
$api->get_user_user_afinimaki($user_id_1, $user_id_2);
Gets user vs user afinimaki. AfinimaKi range is [0.0-1.0].
get_soul_mates
my $soul_mates = $api->get_soul_mates($user_id);
foreach (@$soul_mates) {
print "user_id: $_->{user_id}
afinimaki: $_->{afinimaki}\n";
}
Get a list of user's soul mates (users with similar
tastes). AfinimaKi range is [0.0-1.0].
AUTHORS
WWW::AfinimaKi by Matias Alejo Garcia (matiu at cpan.org)
COPYRIGHT
Copyright (c) 2010 Matias Alejo Garcia. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
SUPPORT / WARRANTY
The WWW::AfinimaKi is free Open Source software. IT COMES WITHOUT WARRANTY OF ANY KIND.
Github repository is at http://github.com/matiu/WWW--AfinimaKi
BUGS
None discovered yet... please let me know if you run into one.