定制 meetdemio/demio-php-sdk 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

meetdemio/demio-php-sdk

最新稳定版本:1.0

Composer 安装命令:

composer create-project meetdemio/demio-php-sdk

包简介

Demio API PHP SDK

README 文档

README

Scrutinizer Code Quality Build Status

This PHP SDK are built for easier working with existing Demio REST API inside PHP projects.

Requirements

  • php >= 5.5
  • composer
  • ext-curl

Installation via Composer

The recommended way to install Demio API PHP SDK is with Composer

curl -sS https://getcomposer.org/installer | php

You can add Demio API PHP SDK as a dependency using the composer.phar CLI:

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:

{  
    "require": {  
        "meetdemio/demio-php-sdk": "dev-master"  
    }  
}  

After installing, you need to require Composer's autoloader:

require 'vendor/autoload.php'; 

Initialization

You need login to your Demio Dashboard and get Api Key and Api Secret.

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

Ping

$response = $client->ping();
echo $response->results()->pong;

Events list

Work with Events is carried out through property events

$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

$events = $client->call('events', [], 'GET');
var_dump($events->results());

Examples

You can find more examples inside examples directory

统计信息

  • 总下载量: 25.23k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 2
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2016-03-22