This package will help you to query OpenAgenda API. It supports all endpoints with all methods (HEAD, GET, POST, PATCH & DELETE).
branch | This package version | OpenAgenda API | PHP min |
---|---|---|---|
3.0.x | 3.0.* | v2 | PHP 7.2 |
3.x | ^3.1 | v2 | PHP 8.0 |
The sdk is not directly usable.
You need to use one client wrapper, compatible with your PSR-18 http client or framework.
Please check version map in the README
of your desired wrapper.
erwane/openagenda-wrapper-cakephp
composer require erwane/openagenda-wrapper-cakephp
erwane/openagenda-wrapper-guzzle
composer require erwane/openagenda-wrapper-guzzle
This package require wrapper compatible with your PSR-18 Http client (psr/http-client
).
For performance and reduce queries in post
, patch
& delete
(authenticated request), you can configure a PSR 16 cache (psr/simple-cache
).
use OpenAgenda\OpenAgenda;
use OpenAgenda\Wrapper\GuzzleWrapper
// PSR-18 Http client.
$guzzleOptions = ['timeout' => 2.0];
$wrapper = new GuzzleWrapper($guzzleOptions);
// PSR-16 Simple cache. Optional
$cache = new Psr16Cache();
// Create the OpenAgenda client. The public key is required for reading data (GET)
// The private key is optional and only needed for writing data (POST, PUT, DELETE)
$oa = new OpenAgenda([
'public_key' => 'my public key', // Required
'secret_key' => 'my secret key', // Optional, only for create/update/delete
'wrapper' => $wrapper, // Required
'cache' => $cache, // Optional
'defaultLang' => 'fr', // Optional
]);
Agendas
$agendas = $oa->myAgendas(['limit' => 2]);
$agenda = $oa->agendas(['slug' => 'agenda-slug'])->first();
See agendas for more details.
Locations
// Search
$locations = $oa->locations(['agendaUid' => 123, 'name' => 'My Location']);
// Exists and get
$exists = $oa->location(['uid' => 456, 'agendaUid' => 123])->exists();
$location = $oa->location(['uid' => 456, 'agendaUid' => 123])->get();
// Create
$location = $oa->location($data)->create();
See locations for more details.
Events
// Search
$events = $oa->events(['agendaUid' => 123, 'title' => 'My event']);
// Exists and get
$exists = $oa->event(['uid' => 456, 'agendaUid' => 123])->exists();
$event = $oa->event(['uid' => 456, 'agendaUid' => 123])->get();
// Create
$event = $oa->event($data)->create();
See events for more details.