Пример #1
0
 /**
  * @param string  $artist
  * @param string  $albumName
  * @param boolean $titlePrecision
  *
  * @return \SimpleXMLElement
  *
  * @throws \Exception
  */
 public function tracksSearch($artist = "", $albumName = "", $titlePrecision = false)
 {
     if (!isset($this->conf) && !isset($this->apaiIO)) {
         $this->setUp();
     }
     if (empty($artist)) {
         throw new \InvalidArgumentException(sprintf("artist argument passed to %s must be a string and cannot be null", __METHOD__));
     }
     if (empty($albumName)) {
         throw new \InvalidArgumentException(sprintf("albumName argument passed to %s must be a string and cannot be null", __METHOD__));
     }
     $search = new Search();
     $search->setCategory('Music')->setCondition('All')->setRelationshipType('Tracks')->setResponseGroup(array('ItemAttributes', 'Tracks', 'Images'))->setKeywords(sprintf("%s %s", $artist, $albumName));
     // title value makes search fail more often
     if ($titlePrecision) {
         $search->setTitle($albumName);
     }
     $xmlResponse = $this->apaiIO->runOperation($search);
     return new \SimpleXMLElement($xmlResponse);
 }