-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtest.php
40 lines (37 loc) · 1.32 KB
/
test.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?
$LOOKUP_URL = "http://isbndb.com/api/books.xml?";
$LOOKUP_KEY = "58EJBTZO"; // this is Derek Leung's
function info($fisbn, &$isbn10, &$isbn13, &$title, &$title_ext, &$author, &$publisher, $dump = false) {
global $LOOKUP_URL, $LOOKUP_KEY;
$full_url = $LOOKUP_URL . "access_key=" . $LOOKUP_KEY . "&index1=isbn&value1=" . $fisbn;
$contents = file_get_contents($full_url);
$parser = xml_parser_create();
xml_parse_into_struct($parser, $contents, $values, $index);
xml_parser_free($parser);
$num_results = $values[$index['BOOKLIST'][0]]['attributes']['total_results'];
if($num_results == 0) { // bad ISBN
return false;
}
// now retrieve data from the very first result
$indx = $index['BOOKDATA'][0]; // get index of very first result's data
$isbn10 = $values[$indx]['attributes']['ISBN'];
$isbn13 = $values[$indx]['attributes']['ISBN13'];
$title = $values[$index['TITLE'][0]]['value'];
$title_ext = $values[$index['TITLELONG'][0]]['value'];
$author = $values[$index['AUTHORSTEXT'][0]]['value'];
$publisher = $values[$index['PUBLISHERTEXT'][0]]['value'];
}
info('0393312836', $is10, $is13, $tit, $ext, $auth, $pub);
/*echo $is10;
echo '<br />';
echo $is13;
echo '<br />';
echo $tit;
echo '<br />';
echo $ext;
echo '<br />';
echo $auth;
echo '<br />';
echo $pub;
echo '<br />';
*/