Isbndb.com PHP wrapper
I was working on indexing my bookcollection this weekend and while looking at the stacks of books I had lying around I decided I wasn’t, under any circumstance, going to enter all the data from those books (ISBN/ISBN13, Author, Title, Summary, Publisher, etc) by hand.
So after googling around a bit I found ISBNDB.com which is, in essence, google for books. They crawl the internet searching for bookrelated data and then indexing it themselves. They really do store alot of information about books and cross index that so you can technically search for the categories an author fits in and then search other authors that fit in those same categories.
The best part is though, that they publish all this information through a free webservice. So I wrote a wrapper for this webservice that exposes all the methods and results used that can be used in PHP. If you are interested you can download it here. Documentation here.
Code after the jump:
A quick list of the feautures:
Features:
- Implements paging mechanism used by the webservice
- Can represent all data currently returned by the webservice
- Can handle all request types currently used by the webservice
- Makes pages and resultset function as iterators
It’s fully documented with examples but if you have any questions or requests please let me know, my email is included in the LICENSE file.
An example of how this works is:
/**
* Instantiate the webservice using your access key
*/
$service = new ISBNDBService('MYKEY');
/**
* Do a search on books by the author identified by person_id 'mark_gimenez'
* return bookdetails and a complete list of authors
*/
$booksPaginator = $service->search(ISBNDBService::API_BOOKS,
ISBNDBService::SEARCH_TYPE_PERSON_ID,
'mark_gimenez',
array(ISBNDBService::RESULT_TYPE_DETAILS,
ISBNDBService::RESULT_TYPE_AUTHORS));
/**
* Loop through all the pages of the search results
*/
foreach($booksPaginator as $booksCollection)
{
/**
* Print the list of authors & the title for each result (in this case a ISBNDBServiceBook)
*/
foreach($booksCollection as $book)
{
print $book->title;
print ' - ';
print $book->getAuthorsListAsString();
print '<br />'.PHP_EOL;
}
}
4 Comments »
RSS feed for comments on this post. TrackBack URL
[...] the original post: Linde002::PHP » Isbndb.com PHP wrapper Posted in PHP | Tags: and-while, bookcollection, books, data, enter-all, had-lying, [...]
[...] Excerpt from: Linde002::PHP » Isbndb.com PHP wrapper [...]
[...] our example we are going to take a look at a simplified version of my ISBNDB wrapper which uses this technique to transparantly page the results received from the [...]
I tried to use this wrapper, but I keep getting an error message when using it:
Fatal error: Call to undefined method ISBNDBServiceAuthor::getAuthorsListAsString() in /home/content/n/a/n/nanharb/html/favoritebookbuddies/locate-a-book.php on line 68
even though I have included all of the pages with the classes. I can’t figure out where I should instantiate the servicebook class so I can use this function.
Thank you