src/lastfmapi/Api/ArtistApi.php
public function getTopAlbums($methodVars)
    {
        // Check for required variables
        if (!empty($methodVars['artist']) || !empty($methodVars['mbid'])) {
            $vars = array(
                'method' => 'artist.gettopalbums',
                'api_key' => $this->auth->apiKey
            );
            $vars = array_merge($vars, $methodVars);

            if ($call = $this->apiGetCall($vars)) {
                if (count($call->topalbums->album) > 0) {
                    $i = 0;
                    foreach ($call->topalbums->album as $album) {
                        $topAlbums[$i]['rank'] = (string) $album['rank'];
                        $topAlbums[$i]['name'] = (string) $album->name;
                        $topAlbums[$i]['mbid'] = (string) $album->mbid;
                        $topAlbums[$i]['playcount'] = (string) $album->playcount;
                        $topAlbums[$i]['url'] = (string) $album->url;
                        $topAlbums[$i]['image']['small'] = (string) $album->image[0];
                        $topAlbums[$i]['image']['medium'] = (string) $album->image[1];
                        $topAlbums[$i]['image']['large'] = (string) $album->image[2];
                        $i++;
                    }

                    return $topAlbums;
                } else {
                    throw new NoResultsException('Artist has no top albums');
                }
            } else {
                return false;
            }
        } else {
            throw new InvalidArgumentException('You must include artist varialbe in the call for this method');
        }
    }
public function getTopAlbums($methodVars)
    {
        // Check for required variables
        if (!empty($methodVars['artist']) || !empty($methodVars['mbid'])) {
            $vars = array(
                'method' => 'artist.gettopalbums',
                'api_key' => $this->auth->apiKey
            );
            $vars = array_merge($vars, $methodVars);

            if ($call = $this->apiGetCall($vars)) {
                if (count($call->topalbums->album) > 0) {
                    $i = 0;
                    foreach ($call->topalbums->album as $album) {
                        $topAlbums[$i]['rank'] = (string) $album['rank'];
                        $topAlbums[$i]['name'] = (string) $album->name;
                        $topAlbums[$i]['mbid'] = (string) $album->mbid;
                        $topAlbums[$i]['playcount'] = (string) $album->playcount;
                        $topAlbums[$i]['url'] = (string) $album->url;
                        $topAlbums[$i]['image']['small'] = (string) $album->image[0];
                        $topAlbums[$i]['image']['medium'] = (string) $album->image[1];
                        $topAlbums[$i]['image']['large'] = (string) $album->image[2];
                        $i++;
                    }

                    return $topAlbums;
                } else {
                    throw new NoResultsException('Artist has no top albums');
                }
            } else {
                return false;
            }
        } else {
            throw new InvalidArgumentException('You must include artist varialbe in the call for this method');
        }
    }
public function getTopAlbums ( $ methodVars ) { // Check for required variables if ( ! empty ( $ methodVars [ 'artist' ] ) || ! empty ( $ methodVars [ 'mbid' ] ) ) { $ vars = array ( 'method' => 'artist.gettopalbums' , 'api_key' => $ this -> auth -> apiKey ) ; $ vars = array_merge ( $ vars , $ methodVars ) ; if ( $ call = $ this -> apiGetCall ( $ vars ) ) { if ( count ( $ call -> topalbums -> album ) > 0 ) { $ i = 0 ; foreach ( $ call -> topalbums -> album as $ album ) { $ topAlbums [ $ i ] [ 'rank' ] = ( string ) $ album [ 'rank' ] ; $ topAlbums [ $ i ] [ 'name' ] = ( string ) $ album -> name ; $ topAlbums [ $ i ] [ 'mbid' ] = ( string ) $ album -> mbid ; $ topAlbums [ $ i ] [ 'playcount' ] = ( string ) $ album -> playcount ; $ topAlbums [ $ i ] [ 'url' ] = ( string ) $ album -> url ; $ topAlbums [ $ i ] [ 'image' ] [ 'small' ] = ( string ) $ album -> image [ 0 ] ; $ topAlbums [ $ i ] [ 'image' ] [ 'medium' ] = ( string ) $ album -> image [ 1 ] ; $ topAlbums [ $ i ] [ 'image' ] [ 'large' ] = ( string ) $ album -> image [ 2 ] ; $ i ++ ; } return $ topAlbums ; } else { throw new NoResultsException ( 'Artist has no top albums' ) ; } } else { return false ; } } else { throw new InvalidArgumentException ( 'You must include artist varialbe in the call for this method' ) ; } }
Get the top albums for an artist on Last.fm, ordered by popularity
@param array $methodVars An array with the following required values: <i>artist</i> and optional value: <i>limit</i>, <i></i>
@return array
Get the top albums for an artist on Last . fm ordered by popularity