PHP code example of aalfiann / ebook-api-php

1. Go to this page and download the library: Download aalfiann/ebook-api-php 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/ */

    

aalfiann / ebook-api-php example snippets


use aalfiann\EbookAPI\GoogleBook;
n/json');
$ebook = new GoogleBook('YOUR_GOOGLE_API_KEY');

// Search book
echo $ebook->search('vue js')
    
    // you can add filter to search only free-ebooks
    ->filter('free-ebooks')
    
    // you can add projection 'lite'. This tly only support epub.
    ->download('epub')

    // you can add orderBy 'newest'. This will order books start from newest.
    ->orderBy('newest')

    // you can add startIndex 0. First page always start from 0.
    ->startIndex(0)

    // you can add maxResults 10. This will return only 10 item of books. Max value is 40.
    ->maxResults(10)

    // send request to Google Book API
    ->send()

    // get the response from Google Book API
    ->getResponse();

// Get book by title name
$ebook->title('steve jobs')->maxResults(10);

// Get book by title name 'steve jobs' but only return which is having 'Biography' word in title
$ebook->title('steve jobs','Biography')->maxResults(10);

// Get book by author name
$ebook->author('keyes')->maxResults(10);

// Get book by author name 'keyes' but only return which is having 'flowers' word in title
$ebook->author('keyes','flowers')->maxResults(10);

// Get book by subject name
$ebook->subject('Fiction')->maxResults(10);

// Get book by subject name 'Fiction' but only return which is having 'flowers' word in title
$ebook->subject('Fiction','flowers')->maxResults(10);

// Get book by publisher name
$ebook->publisher('OUP Oxford')->maxResults(10);

// Get book by publisher name 'OUP Oxford' but only return which is having 'Law' word in title
$ebook->publisher('OUP Oxford','Law')->maxResults(10);

// Get book by Google Book ID
$ebook->id('BOOK_ID');

// Get book by ISBN
$ebook->isbn('ISBN_ID');

// Get book by LCCN
$ebook->lccn('LCCN_ID');

// Get book by OCLC
$ebook->oclc('OCLC_ID');

// Get bookshelves from user id '109862556655476830073' 
echo $ebook->bookshelves('109862556655476830073')
    
    // you can choose the shelf. For example only shelf with id '1001'
    ->shelf('1001')

    // if you want to show the items inside shelf
    ->retrieve()
    
    // send request to Google Book API
    ->send()
    
    // get response from Google Book API
    ->getResponse();

echo $ebook->send()->getResponse();

echo $ebook->send()->count();

echo $ebook->send(false)->getResponse();

use aalfiann\EbookAPI\GoodReads;
on/json');
$ebook = new GoodReads('YOUR_GOODREADS_API_KEY');

$ebook->path('search/index.xml')
    // Add param 'q' to query
    ->q('steve jobs')
    
    // Add param 'search[Field]' to query more spesific results. default is 'all'
    ->searchField('title')
    
    // You can add 'page' for pagination. Start page is always 1
    ->page(1)
    
    // Send request to GoodReads API
    ->send()
    
    // Get response from GoodReads API
    ->getResponse();

$ebook->path('review/show_by_user_and_book.xml')
    // Add param 'user_id' which is not available inside the class
    ->addParam('user_id',1)
    
    // Add param 'book_id' which is not available inside the class
    ->addParam('book_id',50)

    // Add param '

use aalfiann\EbookAPI\GoodReadsMethod;
n');
$ebook = new GoodReadsMethod('YOUR_GOODREADS_API_KEY');

// Search Book
echo $ebook->searchBook('fiction');

// Search Book about 'fiction' but show at page 3
echo $ebook->searchBook('fiction',3);

// Search Book by Genre 'comedy'
echo $ebook->searchBookByGenre('comedy');

// Get book by GoodReads Internal ID
echo $ebook->getBook('21825181');

// Get book by ISBN
echo $ebook->getBookByISBN('9781451648546');

// Get book by title
echo $ebook->getBookByTitle('vuejs');

composer