Composer package allowing to easily connect and communicate with the Blue Billywig VMS API.

0.97.6 2021-09-17 11:02 UTC

This package is auto-updated.

Last update: 2024-11-17 18:28:35 UTC


README

https://support.bluebillywig.com/vms-rpc-php

The vms rpc client makes it possible to connect to the vms more easily. This is achieved by taking away some of the complexities like connecting to the vms. This document provides a technical summary of the vms rpc client for PHP.

Usage

Getting Started

Create a new instance of BlueBillywig\RPC. This can be done by providing the username and password or the shared secret.

A shared secret can be generated by going to https://YourPublication.bbvms.com/ovp/#/publication/api-keys (where YourPublication needs to be substituted with the name of your publication) and clicking CREATE NEW KEY.

Creating instance with username and password

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

use BlueBillywig\VMSRPC\RPC;

$host = 'https://YourPublication.bbvms.com';
$user = 'UserName';
$password = 'Password';

try {
    $vms = new RPC($host, $user, $password);
} catch (\Exception $e) {
    echo $e->getMessage();
}

Creating instance with shared secret

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

use BlueBillywig\VMSRPC\RPC;

$host = 'https://YourPublication.bbvms.com';
$sharedSecret = '123-1234567890abcdefghijklmnopqrstuv';

try {
    $vms = new RPC($host, null, null, $sharedSecret);
} catch (\Exception $e) {
    echo $e->getMessage();
}

Quick start

The following example demonstrates how to search for a couple of mediaclips and immediately print the embed code for each mediaclip.

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

use BlueBillywig\VMSRPC\RPC;

$host = 'https://YourPublication.bbvms.com';
$sharedSecret = '123-1234567890abcdefghijklmnopqrstuv';
$arProps = array(
    'query' => 'type:mediaclip AND status:published',
    'limit' => '10',
    'sort' =>'createddate desc'
);

try {
    $vms = new RPC($host, null, null, $sharedSecret);

    $search_result = json_decode($vms->json('search', null, $arProps));

    if($search_result->count > 0) {
        foreach($search_result->items as $oMc) {            
            echo '<script type="text/javascript" src="' . $host . '/p/default/c/'.$oMc->id.'.js"></script>';
        }
    }
} catch (\Exception $e) {
    echo $e->getMessage();
}

Function list

Here you can find the available functions within the RPC, which make it possible to execute API requests. More information concerning API requests can be found here: https://support.bluebillywig.com/vms-api-guide

doAction

Execute API request/action and return the result as an array.

array doAction(string $entity, string $action, array $arProps)

$entity: The relevant api entity that you want to query to obtain the desired result. For example mediaclip, mediacliplist, publication or playout.

$action: The action you want to execute. The actions differ per entity, see the API documentation for details. For example for the mediaclip entity possible actions are get, put or getUsageStats.

$arProps: This array will contain required or optional properties needed for the specific request. For example for the action put of the entity mediaclip you'll need to provide at least the property xml, see the example below.

Here an example to update a mediaclip:

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

use BlueBillywig\VMSRPC\RPC;

$host = 'http://YourPublication.bbvms.com';
$user = 'UserName';
$password = 'Password'; 

try {
    $vms = new RPC($host, $user, $password);

    //Set the status to draft
    $arProps = array(
        'xml' => '<media-clip id="1234567" status="draft"></media-clip>'
    );
    $r = $vms->doAction('mediaclip', 'put', $arProps);
} catch (\Exception $e) {
    echo $e->getMessage();
}

And an example to add a new mediaclip including a video-file:

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

use BlueBillywig\VMSRPC\RPC;

$host = 'http://YourPublication.bbvms.com';
$user = 'UserName';
$password = 'Password'; 

try {
    $vms = new RPC($host, $user, $password);

    //Add a new mediaclip, add a file, set the title and set the status.
    $file = getcwd() . "/someVideo.mp4";
    $arProps = array(
        'xml' => '<media-clip title="New mediaclip"  status="draft"></media-clip>', 
        'Filedata' => '@'.$file
    );

    $r = $vms->doAction('mediaclip', 'put', $arProps);
} catch (\Exception $e) {
    echo $e->getMessage();
}

JSON

Execute API request/action and return the result in JSON format. At this moment it's only possible to get results in JSON format for 'get' and 'search' actions on mediaclips, timelines, widgets and zones.

string json(string $entity, int $objectId = null, array $arProps = null)

$entity: The relevant api entity that you want to query to obtain the desired result. For example mediaclip, mediacliplist, publication or playout.

$objectId: (optional) The id of a certain entity, for example the mediaclipid. If $objectId is set the action will become 'get'.

$arProps: (optional) This array contains required or optional properties needed for the specific request.

Below an example to search for a couple of mediaclips.

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

use BlueBillywig\VMSRPC\RPC;

$host = 'http://YourPublication.bbvms.com';
$user = 'UserName';
$password = 'Password'; 

try {
    $vms = new RPC($host, $user, $password);

    $arProps = array(
        'query' => 'type:mediaclip','limit' => '10',
        'sort' =>'createddate desc'
    );
    $r = json_decode($vms->json('search', null, $arProps));
} catch (\Exception $e) {
    echo $e->getMessage();
}

XML

Execute API request/action and return the result in XML format.

string xml(string $entity, int $objectId = null, array $arProps = null)

$entity: The relevant api entity that you want to query to obtain the desired result. For example mediaclip, mediacliplist, publication or playout.

$objectId: (optional) The id of a certain entity, for example the mediaclipid. If $objectId is set the action will become 'get'.

$arProps: (optional) This array contains required or optional properties needed for the specific request. If not set the default action will become 'get'.

Below an example to get global configurations of a publication.

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

use BlueBillywig\VMSRPC\RPC;

$host = 'http://YourPublication.bbvms.com';
$user = 'UserName';
$password = 'Password'; 

try {
    $vms = new RPC($host, $user, $password);

    $r = $vms->xml('publication');
} catch (\Exception $e) {
    echo $e->getMessage();
}

URI

Execute an API request/action and send all properties for the specific request on the query string. This may be useful whether multiple properties with the same key need to be provided, which could be the case for Solr requests.

string uri(string $apiEntityUrl, string $qs = null)

$apiEntityUrl: The relevant api entity that you want to query to obtain the desired result. For example json/mediaclip or json/qstats.

$qs: (optional) The Query String to be send with the request'.

Below an example to get the mainconfig.xml, which contains configuration of your publication such as asset-paths.

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

use BlueBillywig\VMSRPC\RPC;

$host = 'http://YourPublication.bbvms.com';
$user = 'UserName';
$password = 'Password'; 

try {
    $vms = new RPC($host, $user, $password);

    $apiEntityUrl = "";
    $qs = 'mainconfig.xml';

    $r = $vms->uri($apiEntityUrl, $qs);
} catch (\Exception $e) {
    echo $e->getMessage();
}

Unit Testing

To run the PHP unit tests, clone this repository, run composer install and copy tests/config.example.yaml to tests/config.yaml. Update tests/config.yml with the settings that apply to your publication.

Run the tests with on of the following commands.

./vendor/bin/phpunit
composer test