/** * Fetches and normalize the API data * * @param string $url url of patron dump or pint test * @return array patron data */ private function getContent($url) { $arrRawData = array(); $arrData = array(); // get the data and strip out html tags $strResponse = Parser::request($url); $strResponse = trim(strip_tags($strResponse)); if ($strResponse == "") { throw new \Exception("Could not connect to Innovative Patron API"); } else { // cycle thru each line in the response, splitting each // on the equal sign into an associative array $arrRawData = explode("\n", $strResponse); foreach ($arrRawData as $strLine) { $arrLine = explode("=", $strLine); // strip out the code, leaving just the attribute name $arrLine[0] = preg_replace('/\\[[^\\]]{1,}\\]/', "", $arrLine[0]); $arrData[trim($arrLine[0])] = trim($arrLine[1]); } } return $arrData; }
/** * Add reviews from Good Reads */ public function addReviews() { $xerxes_record = $this->getXerxesRecord(); $isbn = $xerxes_record->getISBN(); $key = $this->registry->getConfig("GOOD_READS_API_KEY", false); if ($key != null) { $url = "http://www.goodreads.com/book/isbn?isbn={$isbn}&key={$key}"; $data = Parser::request($url, 5); if ($data != "") { $xml = new \DOMDocument(); $xml->recover = true; $xml->loadXML($data); $this->reviews = $xml; } } }