Php example of querying books on the amazon website by isbn book number _ PHP Tutorial

Source: Internet
Author: User
Tags php example
Php queries the example of books on the amazon website based on the isbn account. Plug-in description: based on the provided 10-digit ISBN 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 Metadatabase 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

The code is as follows:


$ Isbn = '007149216x ';
$ Result = PIPHP_GetBookFromISBN ($ isbn );
If (! $ Result) echo "cocould not find title for ISBN '$ isbn '.";
Else echo"$ 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 =' $ 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 );
}

Based on the provided 10 ISBN book numbers, the Lightning 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...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.