Travel Search 3 - PHP Reference
Qenner provides a PHP Reference implementation for the Search and Taxonomy service.
The reference implementation provides a full api to all public functionality of the services.
Contents
Interfaces
The reference library provides a object-oriented PHP library. See the SearchInterface.php and TaxonomyInterface.php document for public interfaces.
All objects are available within the \QennerSearch namespace or a sub-namespace thereof. (e.g. use QennerSearch\Search;).
Example calls
Below is a very simple call to the criteria function using the reference api.
$client = new \GuzzleHttp\Client();
$search = new Search(client, 'https://search.qenner.com', 'Y0UR-API-KEY-000', true, 'nl-NL');
$response = $search->getCriteria([], ['Country'], []);
if (!response->isError()) {
$criterionSets = $response->getCriterionSets();
$countryCriterionSet = criterionSets[0];
$countries = countryCriterionSet->getCriteria();
$resultCount = $response->getResultCount();
}
The Taxonomy interface works very much the same. Except that responses are not wrapped in a specialized response object, therefore error checking has to be performed a little different.
$client = new \GuzzleHttp\Client();
$taxonomy = new Taxonomy($client, 'https://search.qenner.com', 'Y0UR-API-KEY-000', true, 'nl-NL');
$airports = $taxonomy->getAirports();
if (!$airports instanceof \QennerSearch\model\messages\ErrorResponse) {
error_log('airports '.$airports);
}
PHP Dependencies
The library's only external dependency is GuzzeleHttp, which it expects to be available at the \GuzzeleHttp namespace.
PHP notes
Source version
This reference implementation requires php 8.0, this is currently the lowest supported version of php. The source tries to provide more strict php type hinting syntax, however this is not completely implemented throughout, yet.
Autoload
An autoload file is provided. If for instance the QennerSearch library is placed in a 'vendor' sub-directory of your php document, you can include the following line at the beginning of your file.
require_once __DIR__ . '/vendor/QennerSearch/autoload.php';
Drupal
Place the above line at the top of your drupal .module file and everything is set up.
Download
Use the following link to download the QennerSearch_v022 PHP reference implementation. Checkout the Changes and Updates page, for the latest changes.