PHP code example of takisrs / biblionet-api-wrapper
1. Go to this page and download the library: Download takisrs/biblionet-api-wrapper 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/ */
takisrs / biblionet-api-wrapper example snippets
use takisrs\Biblionet\ApiFetcher;
// Initialize the fetcher class
$fetcher = new ApiFetcher("testuser", "testpsw");
// Fetch a book
$fetchedItems = $fetcher->fetch(ApiFetcher::FETCH_BY_ID, 252822)->getItems();
// Get the Book object
$fetchedBook = reset($fetchedItems);
// Output some info with the help of getters
if ($fetchedBook){
echo $fetchedBook->getTitle() . " => " . $fetchedBook->getLanguage()->getName().PHP_EOL;
}
use takisrs\Biblionet\ApiFetcher;
$fetcher = new ApiFetcher("testuser", "testpsw");
// Fetch current month's books
$fetcher->fetch(ApiFetcher::FETCH_BY_MONTH, date("Y-m"));
// Keep only the hardcopy books
$fetcher->filter('type', 'Βιβλίο', '==');
// Fill the rest with extra data (contributors)
$fetcher->fill([ApiFetcher::FILL_CONTRIBUTORS]);
// Get an array of books
$fetchedItems = $fetcher->getItems();
// Display some info
foreach ($fetchedItems as $item) {
echo "**** " . $item->getTitle() . " ****" . PHP_EOL;
echo "Publication Date: " . $item->getFirstPublishDate()->format("d/m/y") . PHP_EOL;
echo "Weight: " . $item->getWeight() . ' g' . PHP_EOL;
echo "Price: " . $item->getPrice() . ' €' . PHP_EOL;
$contributors = $item->getContributors();
foreach ($contributors as $contributor) {
echo $contributor->getTypeName() . ": " . $contributor->getName() . PHP_EOL;
}
echo PHP_EOL;
}
$fetcher->fetch(ApiFetcher::FETCH_BY_ID, 252986); // specific book
$fetcher->fetch(ApiFetcher::FETCH_BY_ID, [253064, 252986, 252976]); // specific books
$fetcher->fetch(ApiFetcher::FETCH_BY_MONTH); // current month's books
$fetcher->fetch(ApiFetcher::FETCH_BY_MONTH, "2020-10"); // specific month's books
$fetcher->fetch(ApiFetcher::FETCH_BY_MONTH, "2020-10", "2021-01"); // specific period's books
// January's book of the last 3 years
$fetcher->fetch(ApiFetcher::FETCH_BY_MONTH, "2019-01")->fetch(ApiFetcher::FETCH_BY_MONTH, "2020-01")->fetch(ApiFetcher::FETCH_BY_MONTH, "2021-01");
$fetcher->filter('type', 'e-book', '=='); // Keep only the ebooks
$fetcher->filter('place.name', 'Αθήνα', '=='); // Keep only those published in Athens
$fetcher->filter('cover', 'Μαλακό εξώφυλλο', '=='); // Keep only those with a soft cover
$fetcher->filter('availability', 'Κυκλοφορεί', '=='); // Keep only the available ones
$fetcher->filter('id', 253064, '>='); // Keep the books with an id >= 253064
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.