2017 © Pedro Peláez
 

library php-client

PHP client for api.video web services.

image

api-video/php-client

PHP client for api.video web services.

  • Thursday, June 28, 2018
  • by ApiVideo
  • Repository
  • 0 Watchers
  • 0 Stars
  • 0 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 1 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

badge badge badge, (*1)

, (*2)

api.video is an API that encodes on the go to facilitate immediate playback, enhancing viewer streaming experiences across multiple devices and platforms. You can stream live or on-demand online videos within minutes., (*3)

Deprecation warning

This project is deprecated. It won't be updated anymore, no support will be provided, and it may not be fully compatible with the API anymore. Please use https://github.com/apivideo/api.video-php-client instead., (*4)










, (*5)

api.video PHP SDK

Scrutinizer Code Quality Build Status, (*6)

The api.video web-service helps you put video on the web without the hassle. This documentation helps you use the corresponding PHP client., (*7)

Installation

composer require api-video/php-sdk

Quick start

<?php

require_once __DIR__ . '/vendor/autoload.php';

// Authenticate in production environment
$client = ApiVideo\Client\Client::create('yourProductionApiKey');


// Alternatively, authenticate in sandbox environment for testing
$client = ApiVideo\Client\Client::createSandbox('yourSandboxApiKey');

// Create and upload a video resource from local drive
$video = $client->videos->upload(
    '/path/to/video.mp4', 
    array('title' => 'Course #4 - Part B')
);

// Display embed code
echo $video->assets['iframe'];
// 




Advanced usage

<?php
// Create and upload a video resource from online source (third party)
$video = $client->videos->download(
    'https://www.example.com/path/to/video.mp4', 
    'Course #4 - Part B'
);

// Update video properties
$client->videos->update(
    $video->videoId, 
    array(
        'tags' => array('course', 'economics', 'finance')
    )
);

// Search video by tags filter and paginate results
$videos = $client->videos->search(
    array(
        'currentPage' => 1, 
        'pageSize' => 25, 
        'tags' => array('finance')
    )
);

foreach ($videos  as $video) {
    echo $video->title."\n";
}

// Delete video resource
$client->videos->delete($video->videoId);


// Upload a video thumbnail
$client->videos->uploadThumbnail('/path/to/thumbnail.jpg', $video->videoId);

// Update video thumbnail by picking image with video timecode
$client->videos->updateThumbnailWithTimeCode($video->videoId, '00:15:22.05');

// Create players with default values
$player = $client->players->create();

// Get a player
$player = $client->players->get($player->playerId);

// Search a player with paginate results
$players = $client->players->search(array('currentPage' => 1, 'pageSize' => 50));

$properties = array(
    'shapeMargin' => 10,
    'shapeRadius' => 3,
    'shapeAspect' => 'flat',
    'shapeBackgroundTop' => 'rgba(50, 50, 50, .7)',
    'shapeBackgroundBottom' => 'rgba(50, 50, 50, .8)',
    'text' => 'rgba(255, 255, 255, .95)',
    'link' => 'rgba(255, 0, 0, .95)',
    'linkHover' => 'rgba(255, 255, 255, .75)',
    'linkActive' => 'rgba(255, 0, 0, .75)',
    'trackPlayed' => 'rgba(255, 255, 255, .95)',
    'trackUnplayed' => 'rgba(255, 255, 255, .1)',
    'trackBackground' => 'rgba(0, 0, 0, 0)',
    'backgroundTop' => 'rgba(72, 4, 45, 1)',
    'backgroundBottom' => 'rgba(94, 95, 89, 1)',
    'backgroundText' => 'rgba(255, 255, 255, .95)',
    'enableApi' => false,
    'enableControls' => true,
    'forceAutoplay' => false,
    'hideTitle' => false,
    'forceLoop' => false
);

// Update player properties
$client->players->update($player->playerId, $properties);

// Upload player logo
$client->players->uploadLogo('/path/to/logo.png', $playerId, 'https://api.video');


// Delete a player
$client->players->delete($player->playerId);


// Upload video caption
$client->captions->upload(
    'path/to/caption.vtt', 
    array(
        'videoId' => $video->videoId, 
        'language' => 'en'
    )
);

// Get video caption by language
$caption = $client->captions->get($video->videoId, 'en');

// Update the default caption language
$client->captions->updateDefault($video->videoId, 'en', true);

//Delete caption by language
$client->captions->delete($video->videoId, 'en');

// Upload video chapter
$client->chapters->upload(
    'path/to/chapter.vtt', 
    array(
        'videoId' => $video->videoId, 
        'language' => 'en'
    )
);

// Get video chapter by language
$chapter = $client->chapters->get($video->videoId, 'en');

//Delete chapter by language
$client->chapters->delete($video->videoId, 'en');

// Create a live stream container
$liveStream = $client->lives->create('Test live');
// Get the RTMP stream key
$streamKey = $liveStream->streamKey;

//// Raw statistics

// List video player sessions 
$videoSessions = $client->analyticsVideo->search($video->videoId);
// List video player sessions for the month of July 2018 with pagination
$videoSessionsJuly2018 = $client->analyticsVideo->search($video->videoId, '2018-07', array(), array('currentPage' => 1, 'pageSize' => 100));

// Get video session events for a sessionId
$videoSessionEvents = $client->analyticsSessionEvents->get($videoSessions[0]->session->sessionId);

// List video player sessions 
$liveSessions = $client->analyticsLive->search($liveStream->liveStreamId);
// List video player sessions for the month of July 2018 with pagination
$liveSessionsJuly2018 = $client->analyticsLive->search($video->videoId, '2018-07', array(), array('currentPage' => 1, 'pageSize' => 100));

// Get video session events for a sessionId
$liveSessionEvents = $client->analyticsSessionEvents->get($liveSessions[0]->session->sessionId);

// Generate a token for delegated upload
$token = $client->tokens->generate();

Full API

<?php
/*
 *********************************
 *********************************
 *         VIDEO                 *
 *********************************
 *********************************
*/
// Show a video
$client->videos->get($videoId);

// List or search videos
$client->videos->search($parameters = array(), $callback = null);

// Create video properties
$client->videos->create($title, $properties = array());

// Upload a video media file
// Create a video, if videoId is null
$client->videos->upload($source, $properties = array(), $videoId = null);

// Create a video by downloading it from a third party
$client->videos->download($source, $title, $properties = array());

// Update video properties
$client->videos->update($videoId, $properties = array());

// Set video public
$client->videos->setPublic($videoId);

// Set video private
$client->videos->setPrivate($videoId);

// Delete video (file and data)
$client->videos->delete($videoId);

// Get last video request Error
$client->videos->getLastError();

// Delegated upload (generate a token for someone to upload a video into your account)
$token = $client->tokens->generate(); // string(3): "xyz"
// ...then upload from anywhere without authentication:
// $ curl https://ws.api.video/upload?token=xyz -F file=@video.mp4

/*
 *********************************
 *         VIDEO THUMBNAIL       *
 *********************************
*/

// Upload a thumbnail for video
$client->videos->uploadThumbnail($source, $videoId);

// Update video's thumbnail by picking timecode
$client->videos->updateThumbnailWithTimeCode($videoId, $timecode);

// Get last video request Error
$client->videos->getLastError();

/*
 *********************************
 *         VIDEO CAPTIONS        *
 *********************************
*/

// Get caption for a video
$client->captions->get($videoId, $language);

// Get all captions for a video
$client->captions->getAll($videoId);

// Upload a caption file for a video (.vtt)
$client->captions->upload($source, $properties = array());


// Set default caption for a video
$client->captions->updateDefault($videoId, $language, $isDefault);

// Delete video's caption
$client->captions->delete($videoId, $language);

// Get last video captions request Error
$client->captions->getLastError();

/*
 *********************************
 *         VIDEO CHAPTERS        *
 *********************************
*/

// Get chapter for a video
$client->chapters->get($videoId, $language);

// Get all chapters for a video
$client->chapters->getAll($videoId);

// Upload a chapter file for a video (.vtt)
$client->chapters->upload($source, $properties = array());

// Delete video's chapter
$client->chapters->delete($videoId, $language);

// Get last video chapters request Error
$client->chapters->getLastError();


/*
 *********************************
 *         PLAYERS               *
 *********************************
*/

// Get a player
$client->players->get($playerId);

// List players
$client->players->search($parameters = array(), $callback = null);

// Create a player
$client->players->create($properties = array());

// Update player's properties
$client->players->update($playerId, $properties);

// Upload player logo
$client->players->uploadLogo('/path/to/logo.png', $playerId, 'https://api.video');

// Delete a logo
$client->players->deleteLogo($playerId);

// Delete a player
$client->players->delete($playerId);

// Get last players request Error
$client->players->getLastError();

/*
 *********************************
 *********************************
 *         LIVE                 *
 *********************************
 *********************************
*/

// Show a live
$client->lives->get($liveStreamId);

// List or search lives
$client->lives->search($parameters = array(), $callback = null);

// Create live properties
$client->lives->create($name, $properties = array());

// Update live properties
$client->lives->update($liveStreamId, $properties = array());

// Set live public
$client->lives->setPublic($liveStreamId);

// Set live private
$client->lives->setPrivate($liveStreamId);

// Delete live (file and data)
$client->lives->delete($liveStreamId);

// Get last live request Error
$client->lives->getLastError();

/*
 *********************************
 *         LIVE THUMBNAIL       *
 *********************************
*/

// Upload a thumbnail for live
$client->lives->uploadThumbnail($source, $liveStreamId);

/*
 *********************************
 *         ANALYTICS             *
 *********************************
*/

// Search videos analytics between period, filter with tags or metadata
$client->analyticsVideo->search($videoId, $period, $metadata, $parameters);

// Get last video analytics request Error
$client->analyticsVideo->getLastError();

// Search live stream analytics between period, filter with tags or metadata
$client->analyticsLive->search($liveStreamId, $period, $parameters);

// Get last live analytics request Error
$client->analyticsLive->getLastError();

// Get session events analytics
$client->analyticsSessionEvents->search($sessionId, $parameters);

// Get last sesion events analytics request Error
$client->analyticsSessionEvents->getLastError();


Full API Details Implementation

Videos

Function Parameters Description Required Allowed Values
get videoId(string) Video identifier :heavy_check_mark: -
search - - - -
- parameters(array) Search parameters :x:
  • currentPage(int)
  • pageSize(int)
  • sortBy(string)
  • sortOrder(string)
  • title(string)
  • description(string)
  • tags(string|array(string))
  • metadata(array())

| | - | callback(function) | callback function | :x: | - | | create | - | - | - | - | | - | title(string) | Video title | :heavy_check_mark: | - | | - | properties(array) | Video properties | :x: |, (*8)

  • description(string)
  • tags(array(string))
  • playerId(string)
  • metadata(array(
    array(
    'key' => 'Key1',
    'value' => 'value1'
    ),
    array(
    'key' => 'Key2',
    'value' => 'value2'
    )
    )

| | upload | - | - | - | - | | - | source(string) | Video media file | :heavy_check_mark: | - | | - | properties(array) | Video properties | :x: |, (*9)

  • title(string)
  • description(string)
  • tags(array(string))
  • playerId(string)
  • metadata(array(
    array(
    'key' => 'Key1',
    'value' => 'value1'
    ),
    array(
    'key' => 'Key2',
    'value' => 'value2'
    )
    )

| | - | videoId(string) | Video identifier | :x: | - | | download | - | - | - | - | | - | source(string) | Video media file | :heavy_check_mark: | - | | - | title(string) | Video title | :heavy_check_mark: | - | | - | properties(array) | Video properties | :x: |, (*10)

  • description(string)
  • tags(array(string))
  • playerId(string)
  • metadata(array(
    array(
    'key' => 'Key1',
    'value' => 'value1'
    ),
    array(
    'key' => 'Key2',
    'value' => 'value2'
    )
    )

| | uploadThumbnail | - | - | - | - | | - | source(string) | Image media file | :heavy_check_mark: | - | | - | videoId(string) | Video identifier | :heavy_check_mark: | - | | updateThumbnailWithTimeCode | - | - | - | - | | - | videoId(string) | Video identifier | :heavy_check_mark: | - | | - | timecode(string) | Video timecode | :heavy_check_mark: | 00:00:00.00br/(hours:minutes:seconds.frames) | | update | - | - | - | - | | - | videoId()string | Video identifier | :heavy_check_mark: | - | | - | properties(array) | Video properties | :heavy_check_mark: |, (*11)

  • title(string)
  • description(string)
  • tags(array(string))
  • playerId(string)
  • metadata(array(
    array(
    'key' => 'Key1',
    'value' => 'value1'
    ),
    array(
    'key' => 'Key2',
    'value' => 'value2'
    )
    )

| | setPublic | videoId(string) | Video identifier | :heavy_check_mark: | - | | setPrivate | videoId(string) | Video identifier | :heavy_check_mark: | - | | delete | videoId(string) | Video identifier | :heavy_check_mark: | - |, (*12)

Players

Function Parameters Description Required Allowed Values
get playerId(string) Player identifier :heavy_check_mark: -
create properties(array) Player properties :x:
  • shapeMargin(int)
  • shapeRadius(int)
  • shapeAspect(string)
  • shapeBackgroundTop(string)
  • shapeBackgroundBottom(string)
  • text(string)
  • link(string)
  • linkHover(string)
  • linkActive(string)
  • trackPlayed(string)
  • trackUnplayed(string)
  • trackBackground(string)
  • backgroundTop(string)
  • backgroundBottom(string)
  • backgroundText(string)
  • enableApi(bool)
  • enableControls(bool)
  • forceAutoplay(bool)
  • hideTitle(bool)
         |

| update | - | - | - | - | | - | playerId(string) | Player identifier | :heavy_check_mark: | - | | - | properties(array) | Player properties | :heavy_check_mark: |, (*13)

  • shapeMargin(int)
  • shapeRadius(int)
  • shapeAspect(string)
  • shapeBackgroundTop(string)
  • shapeBackgroundBottom(string)
  • text(string)
  • link(string)
  • linkHover(string)
  • linkActive(string)
  • trackPlayed(string)
  • trackUnplayed(string)
  • trackBackground(string)
  • backgroundTop(string)
  • backgroundBottom(string)
  • backgroundText(string)
  • enableApi(bool)
  • enableControls(bool)
  • forceAutoplay(bool)
  • hideTitle(bool)
          |

| uploadLogo | - | - | - | - | | - | source(string) | Image media file | :heavy_check_mark: | - | | - | playerId(string) | Player identifier | :heavy_check_mark: | - | | - | link(string) | Link url | :x: | - | | deleteLogo | playerId(string) | Player identifier | :heavy_check_mark: | - | | delete | playerId(string) | Player identifier | :heavy_check_mark: | - |, (*14)

Captions

Function Parameters Description Required Allowed Values
get - - - -
- videoId(string) Video identifier :heavy_check_mark: -
- language(string) Language identifier :heavy_check_mark: 2 letters (ex: en, fr)
getAll videoId(string) Video identifier :heavy_check_mark: -
upload - - - -
- source(string) Caption file :heavy_check_mark: -
- properties(string) Caption properties :heavy_check_mark:
  • videoId(string)
  • language(string - 2 letters)

| | updateDefault | - (array) | - | - | - | | - | videoId | Video identifier | :heavy_check_mark: | - | | - | language (string) | Language identifier | :heavy_check_mark: | 2 letters (ex: en, fr) | | - | isDefault (string) | Set default language | :heavy_check_mark: | true/false | | delete | - (boolean) | - | - | - | | - | videoId | Video identifier | :heavy_check_mark: | - | | - | language (string) | Language identifier | :heavy_check_mark: | 2 letters (ex: en, fr) |, (*15)

Chapters

Function Parameters Description Required Allowed Values
get - - - -
- videoId(string) Video identifier :heavy_check_mark: -
- language(string) Language identifier :heavy_check_mark: 2 letters (ex: en, fr)
getAll videoId(string) Video identifier :heavy_check_mark: -
upload - - - -
- source(string) Chapter file :heavy_check_mark: -
- properties(string) Chapter properties :heavy_check_mark:
  • videoId(string)
  • language(string - 2 letters)

| | delete | - (boolean) | - | - | - | | - | videoId | Video identifier | :heavy_check_mark: | - | | - | language (string) | Language identifier | :heavy_check_mark: | 2 letters (ex: en, fr) |, (*16)

Live streams

Function Parameters Description Required Allowed Values
get liveStreamId(string) Live identifier :heavy_check_mark: -
search - - - -
- parameters(array) Search parameters :x:
  • currentPage(int)
  • pageSize(int)
  • sortBy(string)
  • sortOrder(string)

| | - | callback(function) | callback function | :x: | - | | create | - | - | - | - | | - | name(string) | Live name | :heavy_check_mark: | - | | - | properties(array) | Live properties | :x: |, (*17)

  • record(boolean)
  • playerId(string)

| | uploadThumbnail | - | - | - | - | | - | source(string) | Image media file | :heavy_check_mark: | - | | - | liveStreamId(string) | Live identifier | :heavy_check_mark: | - | | update | - | - | - | - | | - | liveStreamId(string) | Live identifier | :heavy_check_mark: | - | | - | properties(array) | Live properties | :heavy_check_mark: |, (*18)

  • title(string)
  • description(string)
  • tags(array(string))
  • playerId(string)
  • metadata(array(
    array(
    'key' => 'Key1',
    'value' => 'value1'
    ),
    array(
    'key' => 'Key2',
    'value' => 'value2'
    )
    )

| | setPublic | liveStreamId(string) | Live identifier | :heavy_check_mark: | - | | setPrivate | liveStreamId(string) | Live identifier | :heavy_check_mark: | - | | delete | liveStreamId(string) | Live identifier | :heavy_check_mark: | - |, (*19)

AnalyticsVideo

Function Parameters Description Required Allowed Values/Format
search parameters(array) Search parameters :x:
  • Pagination/Filters:
  • currentPage(int)
  • pageSize(int)
  • sortBy(string)
  • sortOrder(string)
  • tags(string|array(string))
  • metadata(array(string))
  • Period:
  • For a day : 2018-01-01
  • For a week: 2018-W01
  • For a month: 2018-01
  • For a year: 2018
  • Date range: 2018-01-01/2018-01-15
  • Week range: 2018-W01/2018-W03
  • Month range: 2018-01/2018-03
  • Year range: 2018/2020
         |

| - | videoId(string) | Video identifier | :heavy_check_mark: | - | | - | period (string) | Period research | :x: |, (*20)

  • For a day : 2018-01-01
  • For a week: 2018-W01
  • For a month: 2018-01
  • For a year: 2018
  • Date range: 2018-01-01/2018-01-15
  • Week range: 2018-W01/2018-W03
  • Month range: 2018-01/2018-03
  • Year range: 2018/2020
         |

| - | metadata (array) | Metadata research | :x: | - |, (*21)

AnalyticsLive

Function Parameters Description Required Allowed Values/Format
search parameters(array) Search parameters :x:
  • Pagination/Filters:
  • currentPage(int)
  • pageSize(int)
  • sortBy(string)
  • sortOrder(string)
  • Period:
  • For a day : 2018-01-01
  • For a week: 2018-W01
  • For a month: 2018-01
  • For a year: 2018
  • Date range: 2018-01-01/2018-01-15
  • Week range: 2018-W01/2018-W03
  • Month range: 2018-01/2018-03
  • Year range: 2018/2020
         |

| - | liveStreamId(string) | Live identifier | :heavy_check_mark: | - | | - | period (string) | Period research | :x: |, (*22)

  • For a day : 2018-01-01
  • For a week: 2018-W01
  • For a month: 2018-01
  • For a year: 2018
  • Date range: 2018-01-01/2018-01-15
  • Week range: 2018-W01/2018-W03
  • Month range: 2018-01/2018-03
  • Year range: 2018/2020
         |

AnalyticsSessionEvents

Function Parameters Description Required Allowed Values/Format
search - - - -
- sessionId(string) Session identifier :heavy_check_mark: -
- parameters(array) Search parameters :x:
  • currentPage(int)
  • pageSize(int)

|, (*23)

Tokens

Function Parameters Description Required Allowed Values
generate - Token for delegated upload - -

Account

Function Parameters Description Required Allowed Values
get - Get account informations (quota, features) - -

More on api.video

A full technical documentation is available on https://docs.api.video/, (*24)

The Versions

28/06 2018

dev-master

9999999-dev

PHP client for api.video web services.

  Sources   Download

MIT

The Requires

 

The Development Requires

28/06 2018

0.3

0.3.0.0

PHP client for api.video web services.

  Sources   Download

MIT

The Requires

 

The Development Requires

28/06 2018

0.2

0.2.0.0

PHP client for api.video web services.

  Sources   Download

MIT

The Requires

 

The Development Requires

21/05 2018

0.1

0.1.0.0

PHP client for api.video web services.

  Sources   Download

MIT

The Requires

 

The Development Requires