openagenda / api-sdk
PHP sdk to request OpenAgenda api
Requires
- php: ^8.0
- ext-json: *
- psr/http-message: ^1.0 | ^2.0
Requires (Dev)
- cakephp/cakephp-codesniffer: ^4.0
- guzzlehttp/psr7: ^2.0
- phpunit/phpunit: ^9.6 | ^10.5
- psr/simple-cache: ^2.0 | ^3.0
- symfony/var-dumper: ^v6.0
This package is auto-updated.
Last update: 2025-01-21 14:10:01 UTC
README
This package will help you to query OpenAgenda API. It supports all endpoints with all methods (HEAD, GET, POST, PATCH & DELETE).
Version map
Installation
The sdk is not directly usable.
You need to use one client wrapper, compatible with your PSR-18 http client or framework.
Wrappers
Please check version map in the README
of your desired wrapper.
CakePHP
erwane/openagenda-wrapper-cakephp
composer require erwane/openagenda-wrapper-cakephp
Guzzle
erwane/openagenda-wrapper-guzzle
composer require erwane/openagenda-wrapper-guzzle
Documentations and examples
Quick start
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 ]);
Usages
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.