src/lastfmapi/Api/LibraryApi.php
public function getAlbums($methodVars)
    {
        // Check for required variables
        if (!empty($methodVars['user'])) {
            $vars = array(
                'method' => 'library.getalbums',
                'api_key' => $this->auth->apiKey
            );
            $vars = array_merge($vars, $methodVars);

            if ($call = $this->apiGetCall($vars)) {
                $albums['page'] = (string) $call->albums['page'];
                $albums['perPage'] = (string) $call->albums['perPage'];
                $albums['totalPages'] = (string) $call->albums['totalPages'];
                $i = 0;
                foreach ($call->albums->album as $album) {
                    $albums['results'][$i]['name'] = (string) $album->name;
                    // THIS DOESN'T WORK AS DOCUMENTED  --- $albums['results'][$i]['rank'] = (string) $album['rank'];
                    $albums['results'][$i]['playcount'] = (string) $album->playcount;
                    $albums['results'][$i]['tagcount'] = (string) $album->tagcount;
                    $albums['results'][$i]['mbid'] = (string) $album->mbid;
                    $albums['results'][$i]['url'] = (string) $album->url;
                    $albums['results'][$i]['artist']['name'] = (string) $album->artist->name;
                    $albums['results'][$i]['artist']['mbid'] = (string) $album->artist->mbid;
                    $albums['results'][$i]['artist']['url'] = (string) $album->artist->url;
                    $albums['results'][$i]['image']['small'] = (string) $album->image[0];
                    $albums['results'][$i]['image']['medium'] = (string) $album->image[1];
                    $albums['results'][$i]['image']['large'] = (string) $album->image[2];
                    $i++;
                }
                return $albums;
            } else {
                return false;
            }
        } else {
            throw new InvalidArgumentException('You must include a user variable in the call for this method');
        }
    }
public function getAlbums($methodVars)
    {
        // Check for required variables
        if (!empty($methodVars['user'])) {
            $vars = array(
                'method' => 'library.getalbums',
                'api_key' => $this->auth->apiKey
            );
            $vars = array_merge($vars, $methodVars);

            if ($call = $this->apiGetCall($vars)) {
                $albums['page'] = (string) $call->albums['page'];
                $albums['perPage'] = (string) $call->albums['perPage'];
                $albums['totalPages'] = (string) $call->albums['totalPages'];
                $i = 0;
                foreach ($call->albums->album as $album) {
                    $albums['results'][$i]['name'] = (string) $album->name;
                    // THIS DOESN'T WORK AS DOCUMENTED  --- $albums['results'][$i]['rank'] = (string) $album['rank'];
                    $albums['results'][$i]['playcount'] = (string) $album->playcount;
                    $albums['results'][$i]['tagcount'] = (string) $album->tagcount;
                    $albums['results'][$i]['mbid'] = (string) $album->mbid;
                    $albums['results'][$i]['url'] = (string) $album->url;
                    $albums['results'][$i]['artist']['name'] = (string) $album->artist->name;
                    $albums['results'][$i]['artist']['mbid'] = (string) $album->artist->mbid;
                    $albums['results'][$i]['artist']['url'] = (string) $album->artist->url;
                    $albums['results'][$i]['image']['small'] = (string) $album->image[0];
                    $albums['results'][$i]['image']['medium'] = (string) $album->image[1];
                    $albums['results'][$i]['image']['large'] = (string) $album->image[2];
                    $i++;
                }
                return $albums;
            } else {
                return false;
            }
        } else {
            throw new InvalidArgumentException('You must include a user variable in the call for this method');
        }
    }
public function getAlbums ( $ methodVars ) { // Check for required variables if ( ! empty ( $ methodVars [ 'user' ] ) ) { $ vars = array ( 'method' => 'library.getalbums' , 'api_key' => $ this -> auth -> apiKey ) ; $ vars = array_merge ( $ vars , $ methodVars ) ; if ( $ call = $ this -> apiGetCall ( $ vars ) ) { $ albums [ 'page' ] = ( string ) $ call -> albums [ 'page' ] ; $ albums [ 'perPage' ] = ( string ) $ call -> albums [ 'perPage' ] ; $ albums [ 'totalPages' ] = ( string ) $ call -> albums [ 'totalPages' ] ; $ i = 0 ; foreach ( $ call -> albums -> album as $ album ) { $ albums [ 'results' ] [ $ i ] [ 'name' ] = ( string ) $ album -> name ; // THIS DOESN'T WORK AS DOCUMENTED  --- $albums['results'][$i]['rank'] = (string) $album['rank']; $ albums [ 'results' ] [ $ i ] [ 'playcount' ] = ( string ) $ album -> playcount ; $ albums [ 'results' ] [ $ i ] [ 'tagcount' ] = ( string ) $ album -> tagcount ; $ albums [ 'results' ] [ $ i ] [ 'mbid' ] = ( string ) $ album -> mbid ; $ albums [ 'results' ] [ $ i ] [ 'url' ] = ( string ) $ album -> url ; $ albums [ 'results' ] [ $ i ] [ 'artist' ] [ 'name' ] = ( string ) $ album -> artist -> name ; $ albums [ 'results' ] [ $ i ] [ 'artist' ] [ 'mbid' ] = ( string ) $ album -> artist -> mbid ; $ albums [ 'results' ] [ $ i ] [ 'artist' ] [ 'url' ] = ( string ) $ album -> artist -> url ; $ albums [ 'results' ] [ $ i ] [ 'image' ] [ 'small' ] = ( string ) $ album -> image [ 0 ] ; $ albums [ 'results' ] [ $ i ] [ 'image' ] [ 'medium' ] = ( string ) $ album -> image [ 1 ] ; $ albums [ 'results' ] [ $ i ] [ 'image' ] [ 'large' ] = ( string ) $ album -> image [ 2 ] ; $ i ++ ; } return $ albums ; } else { return false ; } } else { throw new InvalidArgumentException ( 'You must include a user variable in the call for this method' ) ; } }
A paginated list of all the albums in a user's library, with play counts and tag counts
@deprecated as of march 15 2016, 'library.getalbums' service is not available
@param array $methodVars An array with the following required values: <i>user</i> and optional values: <i>page</i>, <i>limit</i>
@return array
A paginated list of all the albums in a user s library with play counts and tag counts