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

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

                    return $topartists;
                } else {
                    throw new NoResultsException('This user has no top artists');
                }
            } else {
                return false;
            }
        } else {
            throw new InvalidArgumentException('You must include artist variable in the call for this method');
        }
    }
public function getTopArtists($methodVars)
    {
        // Check for required variables
        if (!empty($methodVars['user'])) {
            $vars = array(
                'method' => 'user.gettopartists',
                'api_key' => $this->auth->apiKey
            );
            $vars = array_merge($vars, $methodVars);

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

                    return $topartists;
                } else {
                    throw new NoResultsException('This user has no top artists');
                }
            } else {
                return false;
            }
        } else {
            throw new InvalidArgumentException('You must include artist variable in the call for this method');
        }
    }
public function getTopArtists ( $ methodVars ) { // Check for required variables
 if ( ! empty ( $ methodVars [ 'user' ] ) ) { $ vars = array ( 'method' => 'user.gettopartists' , 'api_key' => $ this -> auth -> apiKey ) ; $ vars = array_merge ( $ vars , $ methodVars ) ; if ( $ call = $ this -> apiGetCall ( $ vars ) ) { if ( count ( $ call -> topartists -> artist ) > 0 ) { $ i = 0 ; foreach ( $ call -> topartists -> artist as $ artist ) { $ topartists [ $ i ] [ 'name' ] = ( string ) $ artist -> name ; $ topartists [ $ i ] [ 'rank' ] = ( string ) $ artist [ 'rank' ] ; $ topartists [ $ i ] [ 'playcount' ] = ( string ) $ artist -> playcount ; $ topartists [ $ i ] [ 'mbid' ] = ( string ) $ artist -> mbid ; $ topartists [ $ i ] [ 'url' ] = ( string ) $ artist -> url ; $ topartists [ $ i ] [ 'streamable' ] = ( string ) $ artist -> streamable ; $ topartists [ $ i ] [ 'images' ] [ 'small' ] = ( string ) $ artist -> image [ 0 ] ; $ topartists [ $ i ] [ 'images' ] [ 'medium' ] = ( string ) $ artist -> image [ 1 ] ; $ topartists [ $ i ] [ 'images' ] [ 'large' ] = ( string ) $ artist -> image [ 2 ] ; $ i ++ ; } return $ topartists ; } else { throw new NoResultsException ( 'This user has no top artists' ) ; } } else { return false ; } } else { throw new InvalidArgumentException ( 'You must include artist variable in the call for this method' ) ; } }
Get the top artists listened to by a user. You can stipulate a time period. Sends the overall chart by default
@param array $methodVars An array with the following required values: <i>user</i> and optional value: <i>period</i>
@return array
Get the top artists listened to by a user . You can stipulate a time period . Sends the overall chart by default