2017 © Pedro Peláez
 

project demio-php-sdk

Demio API PHP SDK

image

meetdemio/demio-php-sdk

Demio API PHP SDK

  • Thursday, March 31, 2016
  • by oleksandr-torosh
  • Repository
  • 2 Watchers
  • 3 Stars
  • 1,201 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 34 % Grown

The README.md

Demio API PHP SDK

Scrutinizer Code Quality Build Status, (*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 = $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)

The Versions

31/03 2016

dev-master

9999999-dev

Demio API PHP SDK

  Sources   Download

BSD-3-Clause

The Requires

 

31/03 2016

dev-development

dev-development

Demio API PHP SDK

  Sources   Download

BSD-3-Clause

The Requires

 

22/03 2016

1.0

1.0.0.0

Demio API PHP SDK

  Sources   Download

BSD-3-Clause

The Requires