PHP Classes

File: examples/WorldCatXISBN.php

Recommend this page to a friend!
  Classes of Robert van der Linde   WorldCat XISBN   examples/WorldCatXISBN.php   Download  
File: examples/WorldCatXISBN.php
Role: Example script
Content type: text/plain
Description: Examples of usage
Class: WorldCat XISBN
Retrieve book information using WorldCat xISBN API
Author: By
Last change:
Date: 15 years ago
Size: 1,644 bytes
 

Contents

Class file image Download
<?php
function __autoload($class)
{
    require_once(
'../'.$class.'.php');
}
/**
 * Instantiate the service
 */
$service = new WorldCatXISBNService();

/**
 * Get all editions for the book "Learning Python".
 *
 * Returns a collection with 8 Editions
 */
$collection = $service->getEditions('0596002815');

/**
 * Loops over the collection and prints the language for each edition
 */
foreach($collection as $edition)
{
  print
$edition->lang . '<br />'.PHP_EOL;
}

/**
 * Translates the 10 digit ISBN to a 13 digit ISBN
 * returns '9780596002817'
 */
print $service->to13('0596002815');

/**
 * Translates the 13 digit ISBN back to the 10 digit ISBN
 * returns '0596002815'
 */
print $service->to10('9780596002817');

/**
 * Gets the metadata for isbn '0596002815'
 */
$edition = $service->getMetadata('0596002815');

var_dump($edition);
/**
 * returns:
 * object(Edition)#4 (14) {
  ["oclcnum"]=>
  array(7) {
    [0]=> string(9) "177669176"
    [1]=> string(9) "249274099"
    [2]=> string(9) "253402825"
    [3]=> string(9) "301161087"
    [4]=> string(8) "54619668"
    [5]=> string(8) "55847258"
    [6]=> string(8) "79871142"
  }
  ["lccn"]=> string(10) "2004273129"
  ["form"]=> string(5) "BA DA"
  ["year"]=> string(4) "2003"
  ["lang"]=> string(3) "eng"
  ["title"]=> string(15) "Learning Python"
  ["author"]=> string(30) "by Mark Lutz and David Ascher."
  ["publisher"]=> string(8) "O'Reilly"
  ["city"]=> string(14) "Sebastopol, CA"
  ["originalLang"]=> string(0) ""
  ["isbn"]=> string(10) "0596002815"
  ["edition"]=> string(7) "2nd ed."
  ["url"]=> string(0) ""
  ["area"]=> string(0) ""
}
 */
?>