/** * todo: this should be changed to use Amazon::getMultiAmazonData so only * one call is made if there are multiple isbns. however, that makes it * difficult to keep isbn10/isbn13 distinction. */ public function book($isbn) { global $app; $isbns = explode("-", $isbn); $ret = array(); foreach ($isbns as $isbn) { if (Isbn::validate($isbn) && ($data = Amazon::getAmazonData($isbn))) { // Occasionally Amazon returns data for the book we want, but // with a different ISBN. This preserves the original ISBN. if ($data['isbn'] != Isbn::to13($isbn)) { $itemId = $data['isbn']; } else { $itemId = $isbn; } $ret[] = array('itemId' => $itemId, 'slug' => $itemId, 'data' => $data); } else { $ret[] = array('itemId' => $isbn, 'slug' => $isbn, 'error' => true); } } echo json_encode($ret); $app->stop(); Results::fetchPrices($isbns); }