PHP code example of scriptotek / google-books

1. Go to this page and download the library: Download scriptotek/google-books library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

scriptotek / google-books example snippets



use Scriptotek\GoogleBooks\GoogleBooks;

$books = new GoogleBooks(['key' => 'YOUR_API_KEY_HERE']);

$volume = $books->volumes->get('kdwPAQAAMAAJ');

$volume = $books->volumes->byIsbn('0521339057');

foreach ($books->volumes->search('Hello world') as $vol) {
    echo $vol->title . "\n";
}

$shelf = $books->bookshelves->get('113555231101190020526', '1002');

foreach ($books->bookshelves->byUser('113555231101190020526') as $shelf) {
    echo "<h2>$shelf->title</h2>\n";
    echo "<ul>\n";
    foreach ($shelf->getVolumes() as $vol) {
        echo "  <li>$vol->title</li>\n";
    }
    echo "</ul>\n";
}

$books = new GoogleBooks(['country' => 'NO']);
json
{
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "unknownLocation",
    "message": "Cannot determine user location for geographically restricted operation."
   }
  ],
  "code": 403,
  "message": "Cannot determine user location for geographically restricted operation."
 }
}