ticketpark / php-api-client
A PHP client to use the Ticketpark API
Installs: 1 067
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 3
Forks: 0
Open Issues: 1
Requires
- php: ^8.1|^8.2
- guzzlehttp/guzzle: ^6.5|^7.5
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.27
- phpspec/prophecy: ^1.17
- phpunit/phpunit: ^9.6
- rector/rector: ^0.18.3
README
A PHP client to consume the Ticketpark REST API.
Installation
Add this library to your composer.json:
composer require ticketpark/php-api-client
Usage
Also see example.php
.
Getting data (GET)
<?php include('vendor/autoload.php'); $client = new \Ticketpark\ApiClient\TicketparkApiClient('yourApiKey', 'yourApiSecret'); $client->setUserCredentials('your@username.com', 'yourPassword'); $response = $client->get('/events/', ['maxResults' => 2]); if ($response->isSuccessful()) { $data = $response->getContent(); }
Creating data (POST)
<?php include('vendor/autoload.php'); $client = new \Ticketpark\ApiClient\TicketparkApiClient('yourApiKey', 'yourApiSecret'); $client->setUserCredentials('your@username.com', 'yourPassword'); $response = $client->post('/events/', [ 'host' => 'yourHostPid', 'name' => 'Some great event', 'currency' => 'CHF' ]); if ($response->isSuccessful()) { $pidOfNewEvent = $response->getGeneratedPid(); // if you created a collection of records, the response will contain a link instead // that can be used to fetch the data of the newly generated records. // // $path = $response->getGeneratedListLink(); // $newResponse = $client->get($path); }
Updating data (PATCH)
<?php include('vendor/autoload.php'); $client = new \Ticketpark\ApiClient\TicketparkApiClient('yourApiKey', 'yourApiSecret'); $client->setUserCredentials('your@username.com', 'yourPassword'); $response = $client->patch('/events/yourEventPid', [ 'name' => 'Some changed event name' ] if ($response->isSuccessful()) { // Data was successfully updated }
API credentials
Get in touch to get your API credentials:
support@ticketpark.ch