The Edinburgh Festivals Listings API client for PHP makes it easy for developers to access the Edinburgh Festivals Listings API in their PHP code.
You can get started quickly by installing the client through composer
// Require the Composer autoloader.
require 'vendor/autoload.php';
use FestivalsApi\FestivalsApiClientFactory;
// Instantiate a Festivals API Client.
$client = FestivalsApiClientFactory::createWithCredentials('key', 'secret');
use FestivalsApi\FestivalsApiClientException;
try {
$result = $client->searchEvents(['title' => 'Foo']);
$events = $result->getEvents();
} catch (FestivalsApiClientException $e){
echo "There was an error: " . $e->getMessage();
}
The API delivers results in pages, by default 25 results at a time, configurable up to 100.
Using FestivalsApi\FestivalsApiEventSearch
will take care for the pagination for you so you can iterate all results for a search query easily.
use FestivalsApi\EventSearchIterator;
use FestivalsApi\FestivalsApiClientException;
$search = new EventSearchIterator($client);
$search->setQuery(['festival' => 'jazz']);
try {
foreach ($search as $event){
echo $event['title'];
}
} catch (FestivalsApiClientException $e){
echo "There was an error: " . $e->getMessage();
}
- API Docs - Details about parameters & responses
- API Browser - Interactive tool to explore API options and responses
The recommended way to install the php client is through Composer.
Install Composer https://getcomposer.org/
Next, run the Composer command to install the latest stable version of the client:
composer require festivalslab/api-client-php
After installing, you need to require Composer's autoloader:
require 'vendor/autoload.php';
You can then later update the client using composer:
composer update