PHP code example of priorist / edm-sdk

1. Go to this page and download the library: Download priorist/edm-sdk library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

priorist / edm-sdk example snippets


use Priorist\EDM\Client\Client;

$client = new Client('https://edm.example.com', 'CLIENT_ID', 'CLIENT_SECRET');

// $client now works with global permission, e.g. to read events.

$events = $client->event->findUpcoming();

// To switch to permissions of a given user, e.g. to read participant data, call logIn
// with the user’s login name and password:

$accessToken = $client->logIn('USER_NAME', 'PASSWORD');

$client->event->findParticipating();

// You may store $accessToken in your session to re-use it later:

$client->setAccessToken($accessToken);

$event = $client->event->findById(4711);

if ($event !== null)
    echo $event['event_base_name'] . "\n";
}

$upcomingEvents = $client->event->findUpcoming();

foreach ($upcomingEvents as $event) {
    echo $event['event_base_name'] . "\n";
}

$location = $client->category->findById(4711);

if ($category !== null)
    echo $category['name'] . "\n";
}

$categories = $client->category->findAll();

foreach ($categories as $category) {
    echo $category['name'] . "\n";
}

$location = $client->eventLocation->findById(4711);

if ($location !== null)
    echo $location['name'] . "\n";
}

$locations = $client->eventLocation->findAll();

foreach ($locations as $location) {
    echo $location['name'] . "\n";
}

$lecturer = $client->lecturer->findById(4711);

if ($lecturer !== null)
    echo $lecturer['name'] . "\n";
}

$lecturers = $client->lecturer->findAll();

foreach ($lecturers as $lecturer) {
    echo $lecturer['name'] . "\n";
}

$lecturer = $client->tag->findById(4711);

if ($tag !== null)
    echo $tag['name'] . "\n";
}

$tags = $client->tag->findAll();

foreach ($tags as $tag) {
    echo $tag['name'] . "\n";
}

use Priorist\EDM\Client\Rest\ClientException;

$enrollment = [
    'first_name'    => 'John',
    'last_name'     => 'Doe',
    'event'         => 4711,
    'price'         => 4712,
];

try {
    $enrollment = $client->enrollment->create($enrollment);
} catch (ClientException $e) {
    $errors = $e->getDetails(); // Contains errors for missing/invalid fields/values
}

echo $enrollment['id']; // Holds the resulting ID on success.

$client->event->fetchCollection([
    'ordering' => 'first_day',
    'first_day__gte' => date('Y-m-d'),
]);

$client->getRestClient()->fetchCollection('events', [
    'ordering' => 'first_day',
    'first_day__gte' => date('Y-m-d'),
]);