diff --git a/EANSearch.php b/EANSearch.php index ed87787..75313ab 100644 --- a/EANSearch.php +++ b/EANSearch.php @@ -41,6 +41,17 @@ function barcodeSearch($ean, $lang = 1) { return $response->product; } + // only return the book name + function isbnLookup($isbn) { + $xml = file_get_contents("https://api.ean-search.org/api?" + . "op=barcode-lookup&token=$this->accessToken&isbn=$isbn", false, $this->ctx); + if ($xml === FALSE) { + return ''; + } + $response = new SimpleXMLElement($xml); + return $response->product->name; + } + function barcodePrefixSearch($prefix, $page = 0) { $xml = file_get_contents("https://api.ean-search.org/api?" . "op=barcode-prefix-search&token=$this->accessToken&prefix=$prefix&page=$page", false, $this->ctx); diff --git a/README.md b/README.md index 6de931b..99a96c9 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,10 @@ echo "$ean is $name\n"; $product = $eanSearch->barcodeSearch($ean, 1); echo "$ean is $product->name from category $product->categoryName issued in $product->issuingCountry\n"; +$isbn = '1119578884'; +$title = $eanSearch->isbnLookup($isbn); +echo "$isbn is $title\n"; + $ok = $eanSearch->verifyChecksum($ean); echo "$ean is " . ($ok ? 'valid' : 'invalid') . "\n";