PHP code example of mosai-co / meride-php-sdk

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

    

mosai-co / meride-php-sdk example snippets





use Meride\Api;

// substitute with the URL of your own CMS path
define('MERIDE_URL', "https://cms.meride.tv/CLIENT_NAME");
// define which API version to use (default v2)
define('MERIDE_VERSION', 'v2');
// define your access token, visible inside the CMS
define('MERIDE_ACCESS_TOKEN', 'MERIDE_AUTH_CODE');

// instantiate an API object
$merideApi = new Api(MERIDE_ACCESS_TOKEN, MERIDE_URL, MERIDE_VERSION);





$video = $merideApi->get('video', 1234);
echo $video->title;



$videoCollection = $merideApi->all('video');
// numbers of records in the collection
$videoCount = $videoCollection->count();
// iterating on the records
foreach($videoCollection as $video) {
    echo $video->title."\r\n";
}



// Reading a non-existing video
$video = $merideApi->read('video', 9999);
if ($video->hasErrors())
{
    // some error occured
    $apiResponse = $video->getApiResponse();
    $error = $apiResponse->error;
    if ($apiResponse->httpCode == 404)
    {
        echo "Record not found";
    }
    else
    {
        echo "\r\nError message: ".$error->message;
        echo "\r\nError code: ".$error->errorCode;
    }
}
else
{
    if ($video->isEmpty())
    {
        echo "No data available as the response is empty";
    }
    else
    {
        echo "The video has ID ".$video->id." and title ".$video->title;
    }
}


use Meride\Web\Embed as Embed;
echo Embed::div(array(
    'embedID' => '1594',
    'clientID' => 'webink',
    'width' => '640',
    'height' => '400',
    'bulkLabel' => 'testLabel',
    'autoPlay' => 'true',
    'responsive' => 'true'
));


use Meride\Web\Embed as Embed;
echo Embed::iframe(array(
    'embedID' => '1594',
    'clientID' => 'webink',
    'width' => '640',
    'height' => '400',
    'bulkLabel' => 'testLabel'
));