PHP code example of ethelserth / biblionet-php

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

    

ethelserth / biblionet-php example snippets


use Ethelserth\Biblionet\BiblionetClient;
use GuzzleHttp\Client;
use GuzzleHttp\Psr7\HttpFactory;

$factory = new HttpFactory();

$client = new BiblionetClient(
    httpClient: new Client(),
    requestFactory: $factory,
    streamFactory: $factory,
    username: 'your-username',
    password: 'your-password',
);

// Full title record by Biblionet ID
$title = $client->getTitle(72584);

echo $title->title;          // "Θεραπείας συνέχεια"
echo $title->publisher;      // "Νεφέλη"
echo $title->price;          // "5.8300"
echo $title->summary;        // Full description text
echo $title->coverImage;     // "https://biblionet.gr/wp-content/..."

// By ISBN (dashes are ignored by the API)
$title = $client->getTitleByIsbn('978-960-211-652-4');

// All titles updated on a specific date
$titles = $client->getTitlesByLastUpdate('2024-01-15');

// Paginated month listing (lighter response, no physical details)
$summaries = $client->getMonthTitles(year: 2024, month: 1, page: 1, perPage: 50);

foreach ($summaries as $summary) {
    echo $summary->title;
    echo $summary->publishYear;
}

// Contributors for a title (authors, translators, editors etc.)
$contributors = $client->getContributors(72584);

foreach ($contributors as $contributor) {
    echo $contributor->contributorFullName; // "Νίκη Λοϊζίδη"
    echo $contributor->contributorType;     // "Συγγραφέας"
}

// Companies associated with a title (publisher, distributor etc.)
$companies = $client->getTitleCompanies(72584);

// DDC subjects assigned to a title
$subjects = $client->getTitleSubjects(72584);

foreach ($subjects as $subject) {
    echo $subject->subjectTitle; // "Νεοελληνική πεζογραφία - Προσωπικές αφηγήσεις"
    echo $subject->subjectDdc;   // "889.3"
}

// Full person record by ID
$persons = $client->getPersons(15521);

// All persons updated on a specific date
$persons = $client->getPersonsByLastUpdate('2024-01-15');

// Full company record by ID
$companies = $client->getCompany(212);

// All companies updated on a specific date
$companies = $client->getCompaniesByLastUpdate('2024-01-15');

// Subject with DDC code and parent ID for hierarchy traversal
$subject = $client->getSubject(20);

echo $subject->subjectTitle;  // "Νεοελληνική πεζογραφία - Προσωπικές αφηγήσεις"
echo $subject->subjectDdc;    // "889.3"
echo $subject->subjectParent; // parent subject ID (int) or null

// Language by ID
$language = $client->getLanguage(7);

echo $language->language; // "ισπανικά"

use Ethelserth\Biblionet\Exceptions\BiblionetException;

try {
    $title = $client->getTitle(99999999);
} catch (BiblionetException $e) {
    // API error, HTTP failure, or malformed response
    echo $e->getMessage();
}
bash
composer