xISBN OpenURL Lookup
- Author: Ken Herold
- Additional author(s):
- Institution:
- Year: 2008
- License: BSD style
- Short description: Use, modification and distribution of the code are permitted provided the copyright notice, list of conditions and disclaimer appear in all related material.
- Link to terms: Detailed license terms
- Skill required for using this code:
Choose one of the following: basic, intermediate, technical. Please also add your choice as a tag at the bottom of the page.
Description
Sends OpenURL ISBN data to OCLC Worldcat Web Service for xISBN, retireves the top 5 entries and formats them into a Classic Web Voyage ISBN search.
State
Stable
Working example
http://lib.hamilton.edu:3000/xisbn.php?isbn=9780199212804
Release notes
Presently operating from our 360 Link resolver to our catalog.
Installation instructions
<Code sample> <? $I = $_GET['isbn']; if (strlen($I) == '0') $I = '0000000000'; else // initialize variables ini_set("display_errors","off"); ini_set("register_globals","on"); // test for URL availability if(!($test = fopen("http://labs.oclc.org/xisbn/", "r"))) { print("ISBN unavailable"); exit; } fclose($test); $i=0; $vals = ''; // get results from OCLC $U = 'http://labs.oclc.org/xisbn/' . $I; $fh1 = fopen($U, "r"); while (!feof($fh1)) { $string = $string . fgets($fh1, 1024); } fclose($fh1); // parse results and limit to top five while ($num-$pos <> '11') { if ($i < 5) { get_isbn(); $i++; } else break; } function get_isbn() { global $num; global $pos; global $vals; global $string; $num = strlen($string); $pos = 0; $len = 0; $start = 0; $sub1 = "<isbn>"; $pos = strpos($string, $sub1); $start = $pos + 6; $sub2 = "</isbn>"; $pos = strpos($string, $sub2); $len = $pos - $start; if ($i=0) { $vals = substr($string, $start, $len); } else { $vals = $vals . '+' . substr($string, $start, $len); } $pos = $pos + 7; $string = substr($string, $pos, $num-$pos); } $vals = substr($vals, 1, strlen($vals)-1); // include original number in case OCLC misses // $vals = $vals . '+' . $I; $vals = $I; // send values to ALEX $url = "<Voyager server>/cgi-bin/Pwebrecon.cgi?DB=local&SAB1=" . $vals . "&BOOL1=any+of+these&FLD1=ISBN+%28ISBN%29&CNT=10"; echo ("<meta http-equiv='Refresh' content='0;URL=$url'/>"); // echo $vals; ?> </Code sample>
TO DO list
More elegant use of web served structured data should be crafted.
Known issues
Parsing of the web service is extremely crude string extraction from the XML result.