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

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

            if ($call = $this->apiGetCall($vars)) {
                $tracks['page'] = (string) $call->tracks['page'];
                $tracks['perPage'] = (string) $call->tracks['perPage'];
                $tracks['totalPages'] = (string) $call->tracks['totalPages'];
                $i = 0;
                foreach ($call->tracks->track as $track) {
                    $tracks['results'][$i]['name'] = (string) $track->name;
                    // THIS DOESN'T WORK AS DOCUMENTED  --- $tracks['results'][$i]['rank'] = (string) $track['rank'];
                    $tracks['results'][$i]['playcount'] = (string) $track->playcount;
                    $tracks['results'][$i]['tagcount'] = (string) $track->tagcount;
                    $tracks['results'][$i]['url'] = (string) $track->url;
                    $tracks['results'][$i]['streamable'] = (string) $track->streamable;
                    $tracks['results'][$i]['fulltrack'] = (string) $track->streamable['fulltrack'];
                    $tracks['results'][$i]['artist']['name'] = (string) $track->artist->name;
                    $tracks['results'][$i]['artist']['mbid'] = (string) $track->artist->mbid;
                    $tracks['results'][$i]['artist']['url'] = (string) $track->artist->url;
                    $tracks['results'][$i]['image']['small'] = (string) $track->image[0];
                    $tracks['results'][$i]['image']['medium'] = (string) $track->image[1];
                    $tracks['results'][$i]['image']['large'] = (string) $track->image[2];
                    $i++;
                }
                return $tracks;
            } else {
                return false;
            }
        } else {
            throw new InvalidArgumentException('You must include a user variable in the call for this method');
        }
    }
public function getTracks ( $ methodVars ) { // Check for required variables if ( ! empty ( $ methodVars [ 'user' ] ) ) { $ vars = array ( 'method' => 'library.gettracks' , 'api_key' => $ this -> auth -> apiKey ) ; $ vars = array_merge ( $ vars , $ methodVars ) ; if ( $ call = $ this -> apiGetCall ( $ vars ) ) { $ tracks [ 'page' ] = ( string ) $ call -> tracks [ 'page' ] ; $ tracks [ 'perPage' ] = ( string ) $ call -> tracks [ 'perPage' ] ; $ tracks [ 'totalPages' ] = ( string ) $ call -> tracks [ 'totalPages' ] ; $ i = 0 ; foreach ( $ call -> tracks -> track as $ track ) { $ tracks [ 'results' ] [ $ i ] [ 'name' ] = ( string ) $ track -> name ; // THIS DOESN'T WORK AS DOCUMENTED  --- $tracks['results'][$i]['rank'] = (string) $track['rank']; $ tracks [ 'results' ] [ $ i ] [ 'playcount' ] = ( string ) $ track -> playcount ; $ tracks [ 'results' ] [ $ i ] [ 'tagcount' ] = ( string ) $ track -> tagcount ; $ tracks [ 'results' ] [ $ i ] [ 'url' ] = ( string ) $ track -> url ; $ tracks [ 'results' ] [ $ i ] [ 'streamable' ] = ( string ) $ track -> streamable ; $ tracks [ 'results' ] [ $ i ] [ 'fulltrack' ] = ( string ) $ track -> streamable [ 'fulltrack' ] ; $ tracks [ 'results' ] [ $ i ] [ 'artist' ] [ 'name' ] = ( string ) $ track -> artist -> name ; $ tracks [ 'results' ] [ $ i ] [ 'artist' ] [ 'mbid' ] = ( string ) $ track -> artist -> mbid ; $ tracks [ 'results' ] [ $ i ] [ 'artist' ] [ 'url' ] = ( string ) $ track -> artist -> url ; $ tracks [ 'results' ] [ $ i ] [ 'image' ] [ 'small' ] = ( string ) $ track -> image [ 0 ] ; $ tracks [ 'results' ] [ $ i ] [ 'image' ] [ 'medium' ] = ( string ) $ track -> image [ 1 ] ; $ tracks [ 'results' ] [ $ i ] [ 'image' ] [ 'large' ] = ( string ) $ track -> image [ 2 ] ; $ i ++ ; } return $ tracks ; } 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 tracks in a user's library, with play counts and tag counts
@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 tracks in a user s library with play counts and tag counts