-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.php
32 lines (24 loc) · 990 Bytes
/
example.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php
include('vendor/autoload.php');
// 1. Create client
$client = new \Ticketpark\ApiClient\TicketparkApiClient('yourApiKey', 'yourApiSecret');
// 2a. Set your user credentials
$client->setUserCredentials('[email protected]', 'yourPassword');
// 2b. If possible, set one or both existing tokens
// With frequent requests, re-using tokens results in less api requests than using user credentials only.
//
// $client->setAccessToken('someAccessTokenString');
// $client->setRefreshToken('someRefreshToken');
// 3. Execute the desired command
$response = $client->get('/events/', ['maxResults' => 2]);
// 4. Handle the response
if ($response->isSuccessful()) {
print "Request successful!\n\n";
$events = $response->getContent();
foreach($events as $event) {
print $event['name']."\n";
}
}
// 5. Recommended: Get the tokens and store them to use them again later on
$myAccessToken = $client->getAccessToken();
$myRefreshToken = $client->getRefreshToken();