Exemplo n.º 1
0
    /**
     * Performs a query based on the parameters
     * supplied in the ReleaseFilter object. Returns
     * an array of possible matches with scores, as
     * returned by the musicBrainz XML web service.
     * Note that these types of queries only return some
     * information, and not all the information available
     * about a particular release is available using
     * this type of query. You will need to get the
     * MusicBrainz id (mbid) and perform a lookup with
     * getRelease to return complete information about
     * a release.
     *
     * @return array
     * @param phpBrainz_ReleaseFilter
     *
     */
    public function findRelease(phpBrainz_ReleaseFilter $releaseFilterObj)
    {
        if (sizeof($releaseFilterObj->createParameters()) < 1) {
            throw new Exception('The release filter object needs
	        at least 1 argument to create a query.');
        }
        $queryStr = RELEASE_URL . "?type=xml";
        $args = $releaseFilterObj->createParameters();
        foreach ($args as $key => $value) {
            $args[$key] = utf8_encode($value);
        }
        $queryStr .= "&" . http_build_query($args);
        $xml = simplexml_load_file($queryStr);
        if ($xml === false) {
            throw new Exception("Unable to load XML file. URL: " . $queryStr);
        }
        if (empty($xml->{'release-list'})) {
            return array();
        }
        $releases = array();
        foreach ($xml->{'release-list'}->release as $release) {
            $releaseObj = $this->parseReleaseXML($release);
            $releases[] = $releaseObj;
        }
        return $releases;
    }
Exemplo n.º 2
0
 /**
  * Performs a query based on the parameters
  * supplied in the ReleaseFilter object. Returns 
  * an array of possible matches with scores, as 
  * returned by the musicBrainz XML web service.
  * Note that these types of queries only return some 
  * information, and not all the information available
  * about a particular release is available using
  * this type of query. You will need to get the
  * MusicBrainz id (mbid) and perform a lookup with
  * getRelease to return complete information about 
  * a release.
  *
  * @return array
  * @param phpBrainz_ReleaseFilter
  * 
  */
 public function findRelease(phpBrainz_ReleaseFilter $releaseFilterObj)
 {
     if (sizeof($releaseFilterObj->createParameters()) < 1) {
         die(print "The release filter object needs \n\t        at least 1 argument to create a query.");
     }
     $queryStr = RELEASE_URL . "?type=xml";
     $args = $releaseFilterObj->createParameters();
     foreach ($args as $key => $value) {
         $queryStr .= "&" . $key . "=" . urlencode(utf8_encode($value));
     }
     $xml = simplexml_load_file($queryStr);
     $releases = array();
     foreach ($xml->{'release-list'}->release as $release) {
         $releaseObj = $this->parseReleaseXML($release);
         $releases[] = $releaseObj;
     }
     return $releases;
 }