Demio API PHP SDK
, (*1)
This PHP SDK are built for easier working with existing Demio REST API inside PHP projects., (*2)
Requirements
- php >= 5.5
- composer
- ext-curl
Installation via Composer
The recommended way to install Demio API PHP SDK is with Composer, (*3)
curl -sS https://getcomposer.org/installer | php
You can add Demio API PHP SDK as a dependency using the composer.phar CLI:, (*4)
php composer.phar require meetdemio/demio-php-sdk:dev-master
Alternatively, you can specify demio-php-sdk as a dependency in your project's existing composer.json file:, (*5)
{
"require": {
"meetdemio/demio-php-sdk": "dev-master"
}
}
After installing, you need to require Composer's autoloader:, (*6)
require 'vendor/autoload.php';
Initialization
You need login to your Demio Dashboard and get Api Key and Api Secret., (*7)
require 'vendor/autoload.php';
$api_key = 'IG8a1PUHxa49rn3q250LVVkF84p5w03L';
$api_secret = '1Wf20cConSV1zFiw';
$client = new \Demio\Client($api_key, $api_secret);
Actions
After Client initialization you are ready to work with existing methods.
Every action returns \Demio\Results
object with next methods:
- isSuccess()
- boolean, check if response hasn't error messages
- results($params)
- object, Returns response contents object
- count()
- integer, if response contents is array returns it elements count
- messages()
- array, error messages
- implodeMessages($glue)
- string, concat errors messages array in one string with defined glue
- statusCode()
- integer, response HTTP status code
- getResponse()
- GuzzleHttp Response object, (*8)
Ping
$response = $client->ping();
echo $response->results()->pong;
Events list
Work with Events is carried out through property events, (*9)
$events = $client->events->getList();
if ($events->isSuccess()) {
if ($events->count() > 0) {
foreach ($events->results() as $event) {
echo "{$event->name} ({$event->id}) is {$event->status}<br>";
}
} else {
echo "Events not found<br>";
}
} else {
echo "Errors: {$events->implodeMessages()}<br>";
}
Register
$register = $client->events->register([
'id' => 86, // Event ID
'name' => 'John Doe',
'email' => 'john.doe.29@mailforspam.com'
]);
if ($register->isSuccess()) {
$results = $register->results();
$webinar_join_link = $results->join_link;
} else {
echo $register->statusCode(), "<br>";
echo "Errors: ", $register->implodeMessages('<br>');
}
Register for specified Date
$register = $client->events->register([
'id' => 86, // Event ID
'date_id' => 1575, // Date ID
'name' => 'John Doe',
'email' => 'john.doe.29@mailforspam.com'
]);
Register via Registration page link
$register = $client->events->register([
'ref_url' => 'https://my.demio.com/ref/nI7XKRaVfZdj9CyQ',
'name' => 'John Doe',
'email' => 'john.doe.29@mailforspam.com'
]);
Single Event details
$event = $client->events->getEvent(86);
Getting results as associative array
$events->results(['assoc' => true]);
Plain Demio API call
$client->call($endpoint, $params, $method);
Getting events list via plain call, (*10)
$events = $client->call('events', [], 'GET');
var_dump($events->results());
Examples
You can find more examples inside examples directory, (*11)