1. Home
  2. Integrations
  3. VMS RPC PHP client

VMS RPC PHP client


1.0 | Introduction

The VMS RPC client makes it possible to easily connect to the VMS by removing complexities, like connecting to the VMS network. This page provides a technical summary of the VMS RPC client for PHP.

2.0 | Getting started

Download location: https://packagist.org/packages/bluebillywig/vmsrpc

First, include the VMSRPC via composer.

composer require bluebillywig/vmsrpc;

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

use BlueBillywig\VMSRPC;

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

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

Creating instance with shared secret

use BlueBillywig\VMSRPC;

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

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

Quick start

The following example demonstrates how to search for a couple of media clips and immediately print the embed code for each media clip:

$arProps = array(
    'query' => 'type:mediaclip AND status:published',
    'limit' => '10',
    'sort' =>'createddate desc'
);

// Search action
$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="https://YourPublication.bbvms.com/p/default/c/'.$oMc->id.'.js"></script>';
    }
}

3.0 | Function list

Here, you can find the available functions within the RPC, which make it possible to execute API requests.

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.  Please see the API documentation for details. As an example, possible actions for media clip entity 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.

Here is an example to update a media clip:

include('bootstrap.php');
$usr = 'UserName';
$pwd = 'Password';
$pub = 'http://YourPublication.bbvms.com'; 

$vms=new VMSRpc($pub,$usr, $pwd);

//Set the status to draft
$arProps = array('xml' => '<media-clip id="1234567" status="draft"></media-clip>');
$r = $vms->doAction('mediaclip', 'put', $arProps);

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

include('bootstrap.php');
$usr = 'UserName';
$pwd = 'Password';
$pub = 'http://YourPublication.bbvms.com'; 

$vms=new VMSRpc($pub,$usr, $pwd);

//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);
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 media clips, 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 few media clips:

$vms=new VMSRpc($pub,$usr, $pwd);
$arProps=array('query' => 'type:mediaclip','limit' => '10', 'sort' =>'createddate desc');
$r=json_decode($vms->json('search',null,$arProps));
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 is an example of getting global configurations of a publication:

include('bootstrap.php');
$usr = 'UserName';
$pwd = 'Password';
$pub = 'http://YourPublication.bbvms.com'; 

$vms=new VMSRpc($pub,$usr, $pwd);
$r = $vms->xml('publication');
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:

include('bootstrap.php');
$usr = 'UserName';
$pwd = 'Password';
$pub = 'http://YourPublication.bbvms.com'; 

$vms=new VMSRpc($pub,$usr, $pwd);

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

$r = $vms->uri($apiEntityUrl, $qs);

Was this article helpful?

Related Articles

Contact Support
Can't find the answer you're looking for?
Contact Support