PHP code example of joshbannon / overdrive-client

1. Go to this page and download the library: Download joshbannon/overdrive-client 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/ */

    

joshbannon / overdrive-client example snippets


// Connect to Memcache:
$cache = new \Memcached\Wrapper("defaultPool", array(array("localhost", 11211)));

//Instantiate Library Client            
$client = new OverDriveLibraryAPIClient(
            new \GuzzleHttp\Client(),
            $libraryAuthUrlBase, //https://oauth.overdrive.com
            $libraryAPIUrlBase, //http://api.overdrive.com
            //Provided by OverDrive. Identifies the collection owned by the library. 
            //It appears to be technically possible for a library to have more than one collection with OverDrive.
            $collectionId, 
            $cache);
//Login() stores an access token for subsequent calls. Automatically handles timeout.
$client->login($clientKey, $clientSecret);
$totalCopies = $client->getTotalCopies($itemId);
$numAvailable = $client->getAvailable($itemId);


//Instantiate Patron Client            
$client = new OverDrivePatronAPIClient(
            new \GuzzleHttp\Client(),
            $patronAuthUrlBase,
            $patronAPIUrlBase,
            $libraryAuthUrlBase,
            $libraryAPIUrlBase,
            $collectionId,
            $websiteId,
            $ilsId,
            $notificationEmail,
            $cache);
//Login() stores an access token for subsequent calls. Automatically handles timeout.
$client->login($clientKey, $clientSecret, $username); //$username is generally the patron's barcode
$totalCopies = $client->getTotalCopies($itemId);
$numAvailable = $client->getAvailable($itemId);
$loanOptionsCollection = $client->getLoanOptions($itemId);
$loanOption = $loanOptionsCollection->getLoanOptions()[0]; //Format choice is unimportant for holds. Just take the first
$hold = $client->holdItem($loanOption)


bash
# Install Composer
curl -sS https://getcomposer.org/installer | php