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

            if ($call = $this->apiGetCall($vars)) {
                if (count($call->lovedtracks->track) > 0) {
                    $i = 0;
                    foreach ($call->lovedtracks->track as $track) {
                        $lovedTracks[$i]['name'] = (string) $track->name;
                        $lovedTracks[$i]['mbid'] = (string) $track->mbid;
                        $lovedTracks[$i]['url'] = (string) $track->url;
                        $lovedTracks[$i]['date'] = (string) $track->date['uts'];
                        $lovedTracks[$i]['artist']['name'] = (string) $track->artist->name;
                        $lovedTracks[$i]['artist']['mbid'] = (string) $track->artist->mbid;
                        $lovedTracks[$i]['artist']['url'] = (string) $track->artist->url;
                        $lovedTracks[$i]['images']['small'] = (string) $track->image[0];
                        $lovedTracks[$i]['images']['medium'] = (string) $track->image[1];
                        $lovedTracks[$i]['images']['large'] = (string) $track->image[2];
                        $i++;
                    }

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

            if ($call = $this->apiGetCall($vars)) {
                if (count($call->lovedtracks->track) > 0) {
                    $i = 0;
                    foreach ($call->lovedtracks->track as $track) {
                        $lovedTracks[$i]['name'] = (string) $track->name;
                        $lovedTracks[$i]['mbid'] = (string) $track->mbid;
                        $lovedTracks[$i]['url'] = (string) $track->url;
                        $lovedTracks[$i]['date'] = (string) $track->date['uts'];
                        $lovedTracks[$i]['artist']['name'] = (string) $track->artist->name;
                        $lovedTracks[$i]['artist']['mbid'] = (string) $track->artist->mbid;
                        $lovedTracks[$i]['artist']['url'] = (string) $track->artist->url;
                        $lovedTracks[$i]['images']['small'] = (string) $track->image[0];
                        $lovedTracks[$i]['images']['medium'] = (string) $track->image[1];
                        $lovedTracks[$i]['images']['large'] = (string) $track->image[2];
                        $i++;
                    }

                    return $lovedTracks;
                } else {
                    throw new NoResultsException('This user has no loved tracks');
                }
            } else {
                return false;
            }
        } else {
            throw new InvalidArgumentException('You must include artist variable in the call for this method');
        }
    }
public function getLovedTracks ( $ methodVars ) { // Check for required variables
 if ( ! empty ( $ methodVars [ 'user' ] ) ) { $ vars = array ( 'method' => 'user.getlovedtracks' , 'api_key' => $ this -> auth -> apiKey ) ; $ vars = array_merge ( $ vars , $ methodVars ) ; if ( $ call = $ this -> apiGetCall ( $ vars ) ) { if ( count ( $ call -> lovedtracks -> track ) > 0 ) { $ i = 0 ; foreach ( $ call -> lovedtracks -> track as $ track ) { $ lovedTracks [ $ i ] [ 'name' ] = ( string ) $ track -> name ; $ lovedTracks [ $ i ] [ 'mbid' ] = ( string ) $ track -> mbid ; $ lovedTracks [ $ i ] [ 'url' ] = ( string ) $ track -> url ; $ lovedTracks [ $ i ] [ 'date' ] = ( string ) $ track -> date [ 'uts' ] ; $ lovedTracks [ $ i ] [ 'artist' ] [ 'name' ] = ( string ) $ track -> artist -> name ; $ lovedTracks [ $ i ] [ 'artist' ] [ 'mbid' ] = ( string ) $ track -> artist -> mbid ; $ lovedTracks [ $ i ] [ 'artist' ] [ 'url' ] = ( string ) $ track -> artist -> url ; $ lovedTracks [ $ i ] [ 'images' ] [ 'small' ] = ( string ) $ track -> image [ 0 ] ; $ lovedTracks [ $ i ] [ 'images' ] [ 'medium' ] = ( string ) $ track -> image [ 1 ] ; $ lovedTracks [ $ i ] [ 'images' ] [ 'large' ] = ( string ) $ track -> image [ 2 ] ; $ i ++ ; } return $ lovedTracks ; } else { throw new NoResultsException ( 'This user has no loved tracks' ) ; } } else { return false ; } } else { throw new InvalidArgumentException ( 'You must include artist variable in the call for this method' ) ; } }
Get the last 50 tracks loved by a user
@param array $methodVars An array with the following required values: <i>user</i>
@return array
Get the last 50 tracks loved by a user