Пример #1
0
/**
 * Takes in a : 
 * $wid, string, The widget id 
 * $playlistId, string, The playlist_id
 */
function getKalturaPlaylist($partnerId, $playlistId)
{
    $config = new KalturaConfiguration($partnerId);
    $config->serviceUrl = 'http://www.kaltura.com/';
    $client = new KalturaClient($config);
    $client->startMultiRequest();
    // the session:
    $kparams = array();
    $client->addParam($kparams, 'widgetId', '_' . $partnerId);
    $client->queueServiceActionCall('session', 'startWidgetSession', $kparams);
    // The playlist meta:
    $kparams = array();
    $client->addParam($kparams, 'ks', '{1:result:ks}');
    $client->addParam($kparams, 'id', $playlistId);
    $client->queueServiceActionCall('playlist', 'get', $kparams);
    // The playlist entries:
    $client->queueServiceActionCall('playlist', 'execute', $kparams);
    $rawResultObject = $client->doQueue();
    return array('meta' => (array) $rawResultObject[1], 'playlist' => (array) $rawResultObject[2]);
}
//Creates a window when a video's free preview ends and informs the user of payment options
require_once "kalturaConfig.php";
//Includes the client library and starts a Kaltura session to access the API
//More informatation about this process can be found at
//http://knowledge.kaltura.com/introduction-kaltura-client-libraries
require_once 'client/KalturaClient.php';
$config = new KalturaConfiguration(PARTNER_ID);
$config->serviceUrl = 'http://www.kaltura.com/';
$config->format = KalturaClientBase::KALTURA_SERVICE_FORMAT_PHP;
$client = new KalturaClient($config);
global $USER_ID;
$ks = $client->generateSession(ADMIN_SECRET, $USER_ID, KalturaSessionType::ADMIN, PARTNER_ID);
$client->setKs($ks);
//To optimize, we use multi-request to bundle the 3 API requests together in one call to the server:
$client->startMultiRequest();
//Request #1: get the entry details
$client->media->get($_REQUEST['entryId']);
//Request #2: get the entry's payment metadata
$filter = new KalturaMetadataFilter();
$filter->objectIdEqual = $_REQUEST['entryId'];
//return only metadata for this entry
$filter->metadataProfileIdEqual = PAYPAL_METADATA_PROFILE_ID;
//return only the relevant profile
$client->metadata->listAction($filter);
//since we're limiting to entry id and profile this will return at most 1 result
//Request #3: get the entry's payment metadata
$filter = new KalturaMetadataFilter();
$filter->metadataObjectTypeEqual = KalturaMetadataObjectType::CATEGORY;
//search for all category metadatas
$filter->objectIdIn = '{1:result:categoriesIds}';