Plug-in Description:
The plugin searches the Amazon website for details about the book based on the 10-bit ISBN number provided.
If the result is found, an array of two elements is returned, where the first element is the title of the book, and the second element is the URL address of the book cover abbreviation.
It requires the following parameters: $ISBN 10-bit ISBN
Copy Code code as follows:
$ISBN = ' 007149216X ';
$result = PIPHP_GETBOOKFROMISBN ($ISBN);
if (! $result) echo "Could not find the title for ISBN ' $ISBN '."
else echo "<b> $result [0]";
function Piphp_getbookfromisbn ($ISBN)
{
Plug-in 93:get Book from ISBN
//
This is plug-in looks up a ISBN-10 at Amazon.com and then
Returns the matching book title and a thumbnail image
of the front cover. It requires this argument:
//
$ISBN: The ISBN to look up
//
Updated from the the "function in" to take into
Account changes to the Amazon HTML.
$find = ' <meta name= "description" content= "Amazon: ';
$url = "Http://www.amazon.com/gp/aw/d.html?a= $isbn";
$img = ' Http://ecx.images-amazon.com/images/I ';
$page = @file_get_contents ($url);
if (!strlen ($page)) return array (FALSE);
$ptr 1 = Strpos ($page, $find) + strlen ($find);
if (! $ptr 1) return array (FALSE);
$ptr 2 = Strpos ($page, '/> ', $ptr 1);
$title = substr ($page, $ptr 1, $ptr 2-$ptr 1);
$find = $img;
$ptr 1 = Strpos ($page, $find) + strlen ($find);
$ptr 2 = Strpos ($page, ' "', $ptr 1);
$image = substr ($page, $ptr 1, $ptr 2-$ptr 1);
Return Array ($title, $img. $image);
}