Plugin description:
Based on the provided ten-digit ISBN book number, the plug-in searches for detailed information about the book on the Amazon website.
If the result is found, an array of two elements is returned. The first element is the title of the book, and the second element is the URL address of the thumbnail of the book cover.
It requires the following parameters: $ ISBN 10-bit ISBN Book Number
Copy codeThe Code is as follows:
$ Isbn = '007149216x ';
$ Result = PIPHP_GetBookFromISBN ($ isbn );
If (! $ Result) echo "cocould not find title for ISBN '$ isbn '.";
Else echo " <B> $ result [0]";
Function PIPHP_GetBookFromISBN ($ isbn)
{
// Plug-in 93: Get Book From ISBN
//
// This plug-in looks up an 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 function in the book to take
// 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 );
$ Ptr1 = strpos ($ page, $ find) + strlen ($ find );
If (! $ Ptr1) return array (FALSE );
$ Ptr2 = strpos ($ page, '"/>', $ ptr1 );
$ Title = substr ($ page, $ ptr1, $ ptr2-$ ptr1 );
$ Find = $ img;
$ Ptr1 = strpos ($ page, $ find) + strlen ($ find );
$ Ptr2 = strpos ($ page, '"', $ ptr1 );
$ Image = substr ($ page, $ ptr1, $ ptr2-$ ptr1 );
Return array ($ title, $ img. $ image );
}