PHP code example of janalis / biblindex-client
1. Go to this page and download the library: Download janalis/biblindex-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/ */
janalis / biblindex-client example snippets
use BiblIndex\Client\BiblIndexClient;
$client = new BiblIndexClient(
baseUrl: 'https://www.biblindex.org',
username: '...',
password: '...',
clientId: '...',
clientSecret: '...',
);
$quotations = $client->request('/api/quotations', ['page' => 1]);
// Guzzle
$client = new BiblIndexClient(
baseUrl: 'https://www.biblindex.org',
username: '...',
password: '...',
clientId: '...',
clientSecret: '...',
httpClient: new \GuzzleHttp\Client(['timeout' => 10]),
);
// Symfony HttpClient
$psr18 = new \Symfony\Component\HttpClient\Psr18Client(
\Symfony\Component\HttpClient\HttpClient::create(['timeout' => 10]),
);
$client = new BiblIndexClient(
baseUrl: 'https://www.biblindex.org',
// ...credentials...
httpClient: $psr18,
requestFactory: $psr18,
streamFactory: $psr18,
);
$client = new BiblIndexClient(
baseUrl: 'https://www.biblindex.org',
username: '...',
password: '...',
clientId: '...',
clientSecret: '...',
retries: 3,
);
use BiblIndex\Client\LazyResource;
$collection = $client->request('/api/quotations', ['page' => 1]);
// $collection is a LazyCollection — pages fetched lazily
$item = $collection[0]; // no network call yet
echo $item['@id']; // triggers fetch of /api/quotations/1229419
$client = new BiblIndexClient(
baseUrl: 'https://www.biblindex.org',
username: '...',
password: '...',
clientId: '...',
clientSecret: '...',
accept: 'application/json',
);
$collection = $client->request('/api/quotations', ['page' => 1]);
echo $collection->getLoadedItems(); // items loaded so far (page 1)
// Accessing beyond the current page triggers ?page=N
$item = $collection[2]; // fetches /api/quotations?page=2
echo $item['id']; // reads from the fetched item
bash
php example.php