MoreLikeThis API

This commit is contained in:
Gilles Crettenand
2015-06-18 14:19:12 +02:00
parent 5ebe300c28
commit 240ed85dbc
2 changed files with 45 additions and 4 deletions

View File

@@ -711,6 +711,39 @@ class NetBiblio extends WebService
return array_merge($data, $this->AddBookData($results['books']));
}
/**
* This method return books similar to the one given.
*
* @param int|array $ids One or multiple book ids
* @return array
*/
public function MoreLikeThis($ids)
{
$bs = new BookSearch(false);
$bs->addOrQuery(is_array($ids) ? $ids : array($ids), 'id');
$bs->setHandler('more');
$results = $bs->getResults(0, 5);
return $results['books'];
}
/**
* This method returns books similar to the books already
* loaned by the current user.
*
* @return array
* @throws AuthenticationException
*/
public function MoreLikeLoans()
{
$_SESSION["user"]["login"] = 35;
$loans = $this->getUser()->GetOldLoans();
$ids = array_map(function($l) {
return $l['id'];
}, $loans);
return $this->MoreLikeThis($ids);
}
/**
* This method return a list of suggested titles for the given search terms
* @param string $text