src/lastfmapi/Api/AlbumApi.php
public function search($methodVars)
    {
        // Check for required variables
        if (!empty($methodVars['album'])) {
            $vars = array(
                'method' => 'album.search',
                'api_key' => $this->getAuth()->apiKey
            );
            $vars = array_merge($vars, $methodVars);

            $searchresults = array();
            if ($call = $this->apiGetCall($vars)) {
                $callNamespaces = $call->getDocNamespaces(true);
                // fix missing namespace (sic)
                if (!isset($callNamespaces['opensearch'])) {
                    $call->results->addAttribute('xmlns:xmlns:opensearch', 'http://a9.com/-/spec/opensearch/1.1/');
                    $call = new SimpleXMLElement($call->asXML());
                }
                $opensearch = $call->results->children('http://a9.com/-/spec/opensearch/1.1/');
                if ($opensearch->totalResults > 0) {
                    $searchresults['totalResults'] = (string) $opensearch->totalResults;
                    $searchresults['startIndex'] = (string) $opensearch->startIndex;
                    $searchresults['itemsPerPage'] = (string) $opensearch->itemsPerPage;
                    $i = 0;
                    foreach ($call->results->albummatches->album as $album) {
                        $searchresults['results'][$i]['name'] = (string) $album->name;
                        $searchresults['results'][$i]['artist'] = (string) $album->artist;
                        $searchresults['results'][$i]['id'] = (string) $album->id;
			$searchresults['results'][$i]['mbid'] = (string) $album->mbid;
                        $searchresults['results'][$i]['url'] = (string) $album->url;
                        $searchresults['results'][$i]['streamable'] = (string) $album->streamable;
                        $searchresults['results'][$i]['image']['small'] = (string) $album->image[0];
                        $searchresults['results'][$i]['image']['medium'] = (string) $album->image[1];
                        $searchresults['results'][$i]['image']['large'] = (string) $album->image[2];
                        $i++;
                    }

                    return $searchresults;
                } else {
                    throw new NoResultsException('No results', 90);
                }
            } else {
                return false;
            }
        } else {
            throw new InvalidArgumentException('You must include album variable in the call for this method');
        }
    }
public function search($methodVars)
    {
        // Check for required variables
        if (!empty($methodVars['album'])) {
            $vars = array(
                'method' => 'album.search',
                'api_key' => $this->getAuth()->apiKey
            );
            $vars = array_merge($vars, $methodVars);

            $searchresults = array();
            if ($call = $this->apiGetCall($vars)) {
                $callNamespaces = $call->getDocNamespaces(true);
                // fix missing namespace (sic)
                if (!isset($callNamespaces['opensearch'])) {
                    $call->results->addAttribute('xmlns:xmlns:opensearch', 'http://a9.com/-/spec/opensearch/1.1/');
                    $call = new SimpleXMLElement($call->asXML());
                }
                $opensearch = $call->results->children('http://a9.com/-/spec/opensearch/1.1/');
                if ($opensearch->totalResults > 0) {
                    $searchresults['totalResults'] = (string) $opensearch->totalResults;
                    $searchresults['startIndex'] = (string) $opensearch->startIndex;
                    $searchresults['itemsPerPage'] = (string) $opensearch->itemsPerPage;
                    $i = 0;
                    foreach ($call->results->albummatches->album as $album) {
                        $searchresults['results'][$i]['name'] = (string) $album->name;
                        $searchresults['results'][$i]['artist'] = (string) $album->artist;
                        $searchresults['results'][$i]['id'] = (string) $album->id;
			$searchresults['results'][$i]['mbid'] = (string) $album->mbid;
                        $searchresults['results'][$i]['url'] = (string) $album->url;
                        $searchresults['results'][$i]['streamable'] = (string) $album->streamable;
                        $searchresults['results'][$i]['image']['small'] = (string) $album->image[0];
                        $searchresults['results'][$i]['image']['medium'] = (string) $album->image[1];
                        $searchresults['results'][$i]['image']['large'] = (string) $album->image[2];
                        $i++;
                    }

                    return $searchresults;
                } else {
                    throw new NoResultsException('No results', 90);
                }
            } else {
                return false;
            }
        } else {
            throw new InvalidArgumentException('You must include album variable in the call for this method');
        }
    }
public function search ( $ methodVars ) { // Check for required variables if ( ! empty ( $ methodVars [ 'album' ] ) ) { $ vars = array ( 'method' => 'album.search' , 'api_key' => $ this -> getAuth ( ) -> apiKey ) ; $ vars = array_merge ( $ vars , $ methodVars ) ; $ searchresults = array ( ) ; if ( $ call = $ this -> apiGetCall ( $ vars ) ) { $ callNamespaces = $ call -> getDocNamespaces ( true ) ; // fix missing namespace (sic) if ( ! isset ( $ callNamespaces [ 'opensearch' ] ) ) { $ call -> results -> addAttribute ( 'xmlns:xmlns:opensearch' , 'http://a9.com/-/spec/opensearch/1.1/' ) ; $ call = new SimpleXMLElement ( $ call -> asXML ( ) ) ; } $ opensearch = $ call -> results -> children ( 'http://a9.com/-/spec/opensearch/1.1/' ) ; if ( $ opensearch -> totalResults > 0 ) { $ searchresults [ 'totalResults' ] = ( string ) $ opensearch -> totalResults ; $ searchresults [ 'startIndex' ] = ( string ) $ opensearch -> startIndex ; $ searchresults [ 'itemsPerPage' ] = ( string ) $ opensearch -> itemsPerPage ; $ i = 0 ; foreach ( $ call -> results -> albummatches -> album as $ album ) { $ searchresults [ 'results' ] [ $ i ] [ 'name' ] = ( string ) $ album -> name ; $ searchresults [ 'results' ] [ $ i ] [ 'artist' ] = ( string ) $ album -> artist ; $ searchresults [ 'results' ] [ $ i ] [ 'id' ] = ( string ) $ album -> id ; $ searchresults [ 'results' ] [ $ i ] [ 'mbid' ] = ( string ) $ album -> mbid ; $ searchresults [ 'results' ] [ $ i ] [ 'url' ] = ( string ) $ album -> url ; $ searchresults [ 'results' ] [ $ i ] [ 'streamable' ] = ( string ) $ album -> streamable ; $ searchresults [ 'results' ] [ $ i ] [ 'image' ] [ 'small' ] = ( string ) $ album -> image [ 0 ] ; $ searchresults [ 'results' ] [ $ i ] [ 'image' ] [ 'medium' ] = ( string ) $ album -> image [ 1 ] ; $ searchresults [ 'results' ] [ $ i ] [ 'image' ] [ 'large' ] = ( string ) $ album -> image [ 2 ] ; $ i ++ ; } return $ searchresults ; } else { throw new NoResultsException ( 'No results' , 90 ) ; } } else { return false ; } } else { throw new InvalidArgumentException ( 'You must include album variable in the call for this method' ) ; } }
Search for an album by name. Returns album matches sorted by relevance
@param array $methodVars An array with the following required values: <i>album</i>
@return array
Search for an album by name . Returns album matches sorted by relevance