PHP code example of coviu / coviu-sdk

1. Go to this page and download the library: Download coviu/coviu-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/ */

    

coviu / coviu-sdk example snippets



use coviu\Api\Coviu;

$api_key = 'my_api_key_from_coviu.com';
$api_key_secret = 'my_api_key_secret';

$coviu = new Coviu('api_key', 'key_secret');

date_default_timezone_set('GMT');

$session = array(
  'session_name' => 'A test session with Dr. Who',
  'start_time' => (new \DateTime())->format(\DateTime::ATOM),
  'end_time' => (new \DateTime())->modify('+1 hour')->format(\DateTime::ATOM),
  'picture' => 'http://www.fillmurray.com/200/300'
);

$session = $coviu->sessions->createSession($session);
var_dump($session);


array(8) {
  ["team_id"]=>
  string(36) "bc5f47f1-f990-4d4d-a332-d3aa27ce6b76"
  ["client_id"]=>
  string(36) "440ee0f6-f99a-4515-ad15-da67dc29b0fc"
  ["participants"]=>
  array(0) {
  }
  ["session_id"]=>
  string(36) "6a157415-55cd-45a4-a82f-cd78b52e67b3"
  ["session_name"]=>
  string(27) "A test session with Dr. Who"
  ["start_time"]=>
  string(24) "2016-06-18T12:37:59.000Z"
  ["end_time"]=>
  string(24) "2016-06-18T13:37:59.000Z"
  ["picture"]=>
  string(33) "http://www.fillmurray.com/200/300"
}

$host = array(
  'display_name' => 'Dr. Who',
  'role' => 'host', // or 'guest'
  'picture' => 'http://fillmurray.com/200/300',
  'state' => 'test-state'
);

$participant = $coviu->sessions->addParticipant($session['session_id'], $host);
var_dump($participant);

array(8) {
  ["client_id"]=>
  string(36) "440ee0f6-f99a-4515-ad15-da67dc29b0fc"
  ["display_name"]=>
  string(7) "Dr. Who"
  ["entry_url"]=>
  string(62) "https://coviu.com/session/af1f3606-dfbf-4728-b3ca-8f099ca9024a"
  ["participant_id"]=>
  string(36) "af1f3606-dfbf-4728-b3ca-8f099ca9024a"
  ["picture"]=>
  string(29) "http://fillmurray.com/200/300"
  ["role"]=>
  string(4) "HOST"
  ["session_id"]=>
  string(36) "6de7f062-f6db-4253-93b3-8f45445ce2d9"
  ["state"]=>
  string(10) "test-state"
}

$sessions = $coviu->sessions->getSessions();

var_dump($sessions);

var_dump($coviu->$sessions->getSession($session['session_id']));

array(8) {
  ["team_id"]=>
  string(36) "bc5f47f1-f990-4d4d-a332-d3aa27ce6b76"
  ["client_id"]=>
  string(36) "440ee0f6-f99a-4515-ad15-da67dc29b0fc"
  ["participants"]=>
  array(1) {
    [0]=>
    array(8) {
      ["client_id"]=>
      string(36) "440ee0f6-f99a-4515-ad15-da67dc29b0fc"
      ["display_name"]=>
      string(7) "Dr. Who"
      ["entry_url"]=>
      string(62) "https://coviu.com/session/15142b66-7e26-4c49-a232-bc4aa1126aff"
      ["participant_id"]=>
      string(36) "15142b66-7e26-4c49-a232-bc4aa1126aff"
      ["picture"]=>
      string(29) "http://fillmurray.com/200/300"
      ["role"]=>
      string(4) "HOST"
      ["session_id"]=>
      string(36) "7ec15ff3-87f9-4ec9-9484-6029d5da56a6"
      ["state"]=>
      string(10) "test-state"
    }
  }
  ["session_id"]=>
  string(36) "7ec15ff3-87f9-4ec9-9484-6029d5da56a6"
  ["session_name"]=>
  string(27) "A test session with Dr. Who"
  ["start_time"]=>
  string(24) "2016-06-19T09:32:26.000Z"
  ["end_time"]=>
  string(24) "2016-06-19T10:32:26.000Z"
  ["picture"]=>
  string(33) "http://www.fillmurray.com/200/300"
}

$client = new Coviu($api_key, $key_secret);
$grant = $client->authorizationCode($code);

// Now create a client that acts on behalf of the user
$client2 = new Coviu($api_key, $key_secret, $grant);

// Get the team the user authorized you to access
$res2 = $client2->user-getAuthorizedTeam();

// Get that user's scheduled sessions
$res = $client2->sessions->getSessions();