src/lastfmapi/Api/TrackApi.php
public function getSimilar($methodVars) {
		// Check for required variables
		if ( !empty($methodVars['artist']) && !empty($methodVars['track']) ) {
			$vars = array(
				'method' => 'track.getsimilar',
				'api_key' => $this->auth->apiKey
			);
			$vars = array_merge($vars, $methodVars);

			if ( $call = $this->apiGetCall($vars) ) {
				if ( count($call->similartracks->track) > 0 ) {
					$i = 0;
					foreach ( $call->similartracks->track as $track ) {
						$similar[$i]['name'] = (string) $track->name;
						$similar[$i]['match'] = (string) $track->match;
						$similar[$i]['mbid'] = (string) $track->mbid;
						$similar[$i]['url'] = (string) $track->url;
						$similar[$i]['streamable'] = (string) $track->streamable;
						$similar[$i]['fulltrack'] = (string) $track->streamable['fulltrack'];
						$similar[$i]['artist']['name'] = (string) $track->artist->name;
						$similar[$i]['artist']['mbid'] = (string) $track->artist->mbid;
						$similar[$i]['artist']['url'] = (string) $track->artist->url;
						$similar[$i]['images']['small'] = (string) $track->image[0];
						$similar[$i]['images']['medium'] = (string) $track->image[1];
						$similar[$i]['images']['large'] = (string) $track->image[2];
						$i++;
					}
					return $similar;
				}
				else {
					throw new NoResultsException('This track has no similar tracks');
				}
			}
			else {
				return false;
			}
		}
		else {
			throw new InvalidArgumentException('You must include artist and track varialbes in the call for this method');
		}
	}
public function getSimilar($methodVars) {
		// Check for required variables
		if ( !empty($methodVars['artist']) && !empty($methodVars['track']) ) {
			$vars = array(
				'method' => 'track.getsimilar',
				'api_key' => $this->auth->apiKey
			);
			$vars = array_merge($vars, $methodVars);

			if ( $call = $this->apiGetCall($vars) ) {
				if ( count($call->similartracks->track) > 0 ) {
					$i = 0;
					foreach ( $call->similartracks->track as $track ) {
						$similar[$i]['name'] = (string) $track->name;
						$similar[$i]['match'] = (string) $track->match;
						$similar[$i]['mbid'] = (string) $track->mbid;
						$similar[$i]['url'] = (string) $track->url;
						$similar[$i]['streamable'] = (string) $track->streamable;
						$similar[$i]['fulltrack'] = (string) $track->streamable['fulltrack'];
						$similar[$i]['artist']['name'] = (string) $track->artist->name;
						$similar[$i]['artist']['mbid'] = (string) $track->artist->mbid;
						$similar[$i]['artist']['url'] = (string) $track->artist->url;
						$similar[$i]['images']['small'] = (string) $track->image[0];
						$similar[$i]['images']['medium'] = (string) $track->image[1];
						$similar[$i]['images']['large'] = (string) $track->image[2];
						$i++;
					}
					return $similar;
				}
				else {
					throw new NoResultsException('This track has no similar tracks');
				}
			}
			else {
				return false;
			}
		}
		else {
			throw new InvalidArgumentException('You must include artist and track varialbes in the call for this method');
		}
	}
public function getSimilar ( $ methodVars ) { // Check for required variables
 if ( ! empty ( $ methodVars [ 'artist' ] ) && ! empty ( $ methodVars [ 'track' ] ) ) { $ vars = array ( 'method' => 'track.getsimilar' , 'api_key' => $ this -> auth -> apiKey ) ; $ vars = array_merge ( $ vars , $ methodVars ) ; if ( $ call = $ this -> apiGetCall ( $ vars ) ) { if ( count ( $ call -> similartracks -> track ) > 0 ) { $ i = 0 ; foreach ( $ call -> similartracks -> track as $ track ) { $ similar [ $ i ] [ 'name' ] = ( string ) $ track -> name ; $ similar [ $ i ] [ 'match' ] = ( string ) $ track -> match ; $ similar [ $ i ] [ 'mbid' ] = ( string ) $ track -> mbid ; $ similar [ $ i ] [ 'url' ] = ( string ) $ track -> url ; $ similar [ $ i ] [ 'streamable' ] = ( string ) $ track -> streamable ; $ similar [ $ i ] [ 'fulltrack' ] = ( string ) $ track -> streamable [ 'fulltrack' ] ; $ similar [ $ i ] [ 'artist' ] [ 'name' ] = ( string ) $ track -> artist -> name ; $ similar [ $ i ] [ 'artist' ] [ 'mbid' ] = ( string ) $ track -> artist -> mbid ; $ similar [ $ i ] [ 'artist' ] [ 'url' ] = ( string ) $ track -> artist -> url ; $ similar [ $ i ] [ 'images' ] [ 'small' ] = ( string ) $ track -> image [ 0 ] ; $ similar [ $ i ] [ 'images' ] [ 'medium' ] = ( string ) $ track -> image [ 1 ] ; $ similar [ $ i ] [ 'images' ] [ 'large' ] = ( string ) $ track -> image [ 2 ] ; $ i ++ ; } return $ similar ; } else { throw new NoResultsException ( 'This track has no similar tracks' ) ; } } else { return false ; } } else { throw new InvalidArgumentException ( 'You must include artist and track varialbes in the call for this method' ) ; } }
Get the similar tracks for this track on Last.fm, based on listening data
@param array $methodVars An array with the following required values: <i>artist</i>, <i>track</i>
@return array
Get the similar tracks for this track on Last . fm based on listening data