PHP Sample _php tutorial for querying book information on Amazon Sites based on ISBN ISBN

Source: Internet
Author: User
Plugin Description:
The plugin finds the details of the book on the Amazon Web site, based on the 10-Bit ISBN ISBN 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 ISBN

Copy the Code code as follows:
$ISBN = ' 007149216X ';
$result = PIPHP_GETBOOKFROMISBN ($ISBN);
if (! $result) echo "Could not the 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 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 "function in"
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);

$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);
}

http://www.bkjia.com/PHPjc/735234.html www.bkjia.com true http://www.bkjia.com/PHPjc/735234.html techarticle Plugin Description: The plugin finds the details of the book on the Amazon Web site, based on the 10-Bit ISBN ISBN provided. If the result is found, it returns an array of two elements, the first of which is ...

  • Related Article

    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.