function getPlayList() { // Your Kaltura partner credentials define("PARTNER_ID", "xxxxxxx"); define("ADMIN_SECRET", "xxxxxxx"); $user = "******"; $kconf = new KalturaConfiguration(PARTNER_ID); $kclient = new KalturaClient($kconf); $ksession = $kclient->session->start(ADMIN_SECRET, $user, KalturaSessionType::ADMIN); if (!isset($ksession)) { die("Could not establish Kaltura session. Please verify that you are using valid Kaltura partner credentials."); } $kclient->setKs($ksession); $result = $kclient->playlist->get('0_3x0phjri'); $l = explode(",", $result->playlistContent); foreach ($l as $key => $value) { $filter = new KalturaMetadataFilter(); $filter->objectIdEqual = $value; $metadata = $kclient->metadata->listAction($filter)->objects; $id = $metadata[0]->objectId; if (isset($metadata[0]->xml)) { $xml = $metadata[0]->xml; $meta = new SimpleXMLElement($xml); $amt = (string) $meta->Amt; $taxamt = (string) $meta->Taxamt; } $obj = array("name" => "Video", "number" => $value, "category" => "Digital", "desc" => "my video", "amt" => $amt, "taxamt" => $taxamt); $objArray[] = $obj; } return $objArray; }
/** * get the kaltura client * @param bol $isAdmin default = false * @param $privileges * @return unknown_type */ function getClient($isAdmin = false, $privileges = null) { // get the configuration to use the kaltura client $kalturaConfig = KalturaHelpers::getServiceConfiguration($this->params); // inititialize the kaltura client using the above configurations $kalturaClient = new KalturaClient($kalturaConfig); // get the current logged in user $sessionUser = KalturaHelpers::kalturaGetSessionUser(); if ($isAdmin) { $adminSecret = $this->params->get("kaltura_webservice_admin_secret"); $result = $kalturaClient->startsession($sessionUser, $adminSecret, true, $privileges); } else { $secret = $this->params->get("kaltura_webservice_secret"); $result = $kalturaClient->startsession($sessionUser, $secret, false, $privileges); } if (count(@$result["error"])) { return null; } else { // now lets get the session key $session = $result["result"]["ks"]; // set the session so we can use other service methods $kalturaClient->setKs($session); } return $kalturaClient; }
function get_se_wizard($div, $width, $height, $entryId) { $params = "''"; $url = "''"; $platformUser = "******"" . KalturaHelpers::getSessionUser()->userId . "\""; $kalturaSecret = KalturaHelpers::getPlatformKey("secret", ""); if ($kalturaSecret != null && strlen($kalturaSecret) > 0) { try { $kClient = new KalturaClient(KalturaHelpers::getServiceConfiguration()); $kalturaUser = KalturaHelpers::getPlatformKey("user", ""); $ksId = $kClient->session->start($kalturaSecret, $kalturaUser, KalturaSessionType::USER, null, 86400, "*"); $kClient->setKs($ksId); $url = KalturaHelpers::getSimpleEditorUrl(KalturaHelpers::getPlatformKey("editor", null)); $params = KalturaHelpers::flashVarsToString(KalturaHelpers::getSimpleEditorFlashVars($ksId, $entryId, "entry", "")); } catch (Exception $exp) { $flash_embed = $exp->getMessage(); } $flash_embed = ' <div id="' . $div . '" style="width:' . $width . 'px;height:' . $height . ';"> <script type="text/javascript"> var kso = new SWFObject("' . $url . '", "KalturaSW", "' . $width . '", "' . $height . '", "9", "#ffffff"); kso.addParam("flashVars", "' . $params . '"); kso.addParam("allowScriptAccess", "always"); kso.addParam("allowFullScreen", "TRUE"); kso.addParam("allowNetworking", "all"); if(kso.installedVer.major >= 9) { kso.write("' . $div . '"); } else { document.getElementById("' . $div . '").innerHTML = "Flash player version 9 and above is required. <a href=\\"http://get.adobe.com/flashplayer/\\">Upgrade your flash version</a>"; } </script> '; return $flash_embed; } }
function generate_ks($service_url, $partnerId, $secret, $type = KalturaSessionType::ADMIN, $userId = null, $expiry = null, $privileges = null) { $config = new KalturaConfiguration($partnerId); $config->serviceUrl = $service_url; $client = new KalturaClient($config); $ks = $client->session->start($secret, $userId, $type, $partnerId, $expiry, $privileges); $client->setKs($ks); return $client; }
function isPayItem($entryId) { require_once 'kalturaConfig.php'; require_once 'client/KalturaClient.php'; $config = new KalturaConfiguration(PARTNER_ID); $config->serviceUrl = 'http://www.kaltura.com/'; $client = new KalturaClient($config); global $USER_ID; $ks = $client->generateSession(ADMIN_SECRET, $USER_ID, KalturaSessionType::ADMIN, PARTNER_ID); $client->setKs($ks); $entry = $client->media->get($entryId); $paid = ''; if ($entry->categoriesIds != '') { $categories = explode(',', $entry->categoriesIds); foreach ($categories as $category) { $filter = new KalturaMetadataFilter(); $filter->metadataObjectTypeEqual = KalturaMetadataObjectType::CATEGORY; $filter->objectIdEqual = trim($category); $pager = new KalturaFilterPager(); $pager->pageSize = 500; $pager->pageIndex = 1; $categoryMetadatas = $client->metadata->listAction($filter, $pager)->objects; foreach ($categoryMetadatas as $categoryMetadata) { $categoryMetadataProfile = $client->metadataProfile->get($categoryMetadata->metadataProfileId); if ($categoryMetadata->metadataProfileId == PAYPAL_CATEGORY_METADATA_PROFILE_ID) { $xml = simplexml_load_string($categoryMetadata->xml); if ($paid != 'true') { $paid = strtolower($xml->Paid); } //Only need to find one instance of a paid category break; } } } } //If the video is not part of a paid channel, see if the video itself is paid if ($paid != 'true') { $pager = new KalturaFilterPager(); $pageSize = 50; $pager->pageSize = $pageSize; $metadataFilter = new KalturaMetadataFilter(); $metadataFilter->objectIdEqual = $entryId; $metaResults = $client->metadata->listAction($metadataFilter, $pager)->objects; foreach ($metaResults as $metaResult) { if ($metaResult->metadataProfileId == PAYPAL_METADATA_PROFILE_ID) { $xml = simplexml_load_string($metaResult->xml); $paid = strtolower($xml->Paid); break; } } } if ($paid == '') { echo 'false'; } else { echo $paid; } }
private function establishConnection($ini_file) { $config = new KalturaConfiguration($ini_file["partner_id"]); $config->serviceUrl = $ini_file["service_url"]; $client = new KalturaClient($config); $partnerId = $ini_file["partner_id"]; $ks = $client->session->start($ini_file["admin_secret"], "", KalturaSessionType::ADMIN, $partnerId); $client->setKs($ks); return $client; }
/** * Starts a new session * @param KalturaSessionType $type * @param string $userId */ private function startSession2($type, $userId) { $secret = $type == KalturaSessionType::ADMIN ? self::TEST_ADMIN_SECRET_2 : self::TEST_USER_SECRET_2; $ks = $this->client2->session->start($secret, $userId, $type, self::TEST_PARTNER_ID_2); $this->assertNotNull($ks); if (!$ks) { return false; } $this->client2->setKs($ks); return true; }
function getSessionOnce($itemId, $userId) { //Create a session $conf = new KalturaConfiguration(PARTNER_ID); $client = new KalturaClient($conf); $session = $client->session->start(USER_SECRET, $userId, KalturaSessionType::USER, PARTNER_ID, 86400, 'sview:' . $itemId); if (!isset($session)) { die("Could not establish Kaltura session with OLD session credentials. Please verify that you are using valid Kaltura partner credentials."); } $client->setKs($session); echo $session; }
/** * * Gets an API object from the API - using a client session and KS also using the action get from this service on the object id * * @param KalturaObjectBase $objectInstance * @param string $objectId * @param int $partnerId * @param string $secret * @param string $serviceUrl * @param string $service * @throws KalturaAPIException */ private static function getAPIObject(KalturaObjectBase $objectInstance, $objectId, $partnerId, $secret, $serviceUrl, $service) { //here we create the KS and get the data from the API calls $config = new KalturaConfiguration((int) $partnerId); $config->serviceUrl = $serviceUrl; $client = new KalturaClient($config); $ks = $client->session->start($secret, null, KalturaSessionType::ADMIN, (int) $partnerId, null, null); $client->setKs($ks); $entryId = $objectId; $result = $client->{$service}->get($entryId); return $result; }
/** * @param KSchedularTaskConfig $taskConfig */ public function __construct($taskConfig = null) { /* * argv[0] - the script name * argv[1] - serialized KSchedulerConfig config */ global $argv, $g_context; $this->sessionKey = uniqid('sess'); $this->start = microtime(true); if (is_null($taskConfig)) { $data = gzuncompress(base64_decode($argv[1])); self::$taskConfig = unserialize($data); } else { self::$taskConfig = $taskConfig; } if (!self::$taskConfig) { die("Task config not supplied"); } date_default_timezone_set(self::$taskConfig->getTimezone()); // clear seperator between executions KalturaLog::debug('___________________________________________________________________________________'); KalturaLog::stderr('___________________________________________________________________________________', KalturaLog::DEBUG); KalturaLog::info(file_get_contents(dirname(__FILE__) . "/../VERSION.txt")); if (!self::$taskConfig instanceof KSchedularTaskConfig) { KalturaLog::err('config is not a KSchedularTaskConfig'); die; } KalturaLog::debug("set_time_limit({" . self::$taskConfig->maximumExecutionTime . "})"); set_time_limit(self::$taskConfig->maximumExecutionTime); KalturaLog::debug('This batch index: ' . $this->getIndex()); KalturaLog::debug('This session key: ' . $this->sessionKey); self::$kClientConfig = new KalturaConfiguration(); self::$kClientConfig->setLogger($this); self::$kClientConfig->serviceUrl = self::$taskConfig->getServiceUrl(); self::$kClientConfig->curlTimeout = self::$taskConfig->getCurlTimeout(); if (isset(self::$taskConfig->clientConfig)) { foreach (self::$taskConfig->clientConfig as $attr => $value) { self::$kClientConfig->{$attr} = $value; } } self::$kClient = new KalturaClient(self::$kClientConfig); self::$kClient->setPartnerId(self::$taskConfig->getPartnerId()); self::$clientTag = 'batch: ' . self::$taskConfig->getSchedulerName() . ' ' . get_class($this) . " index: {$this->getIndex()} sessionId: " . UniqueId::get(); self::$kClient->setClientTag(self::$clientTag); //$ks = self::$kClient->session->start($secret, "user-2", KalturaSessionType::ADMIN); $ks = $this->createKS(); self::$kClient->setKs($ks); KDwhClient::setEnabled(self::$taskConfig->getDwhEnabled()); KDwhClient::setFileName(self::$taskConfig->getDwhPath()); $this->onBatchUp(); KScheduleHelperManager::saveRunningBatch($this->getName(), $this->getIndex()); }
private function getKalturaClient($partnerId, $adminSecret, $isAdmin) { $kConfig = new KalturaConfiguration($partnerId); $kConfig->serviceUrl = KalturaTestConfiguration::SERVICE_URL; $client = new KalturaClient($kConfig); $userId = "SomeUser"; $sessionType = $isAdmin ? KalturaSessionType::ADMIN : KalturaSessionType::USER; try { $ks = $client->generateSession($adminSecret, $userId, $sessionType, $partnerId); $client->setKs($ks); } catch (Exception $ex) { die("could not start session - check configurations in KalturaTestConfiguration class"); } return $client; }
private function getKalturaClient($partnerId, $adminSecret, $isAdmin) { $kConfig = new KalturaConfiguration(); $kConfig->serviceUrl = $this->config[self::CONFIG_ITEM_SERVICE_URL]; $kConfig->setLogger($this); $client = new KalturaClient($kConfig); $userId = "SomeUser"; $sessionType = $isAdmin ? KalturaSessionType::ADMIN : KalturaSessionType::USER; try { $ks = $client->generateSession($adminSecret, $userId, $sessionType, $partnerId); $client->setKs($ks); } catch (Exception $ex) { throw new Exception("Could not start session - check configurations in config.ini"); } return $client; }
private function initClient() { echo 'initClient' . PHP_EOL; if ($this->client) { return; } try { $config = new KalturaConfiguration(Config::PARTNER_ID); $config->serviceUrl = Config::SERVER_URL; $client = new KalturaClient($config); $ks = $client->session->start(Config::PARTNER_ADMIN_SECRET, Config::PARTNER_USER_ID, KalturaSessionType::ADMIN, Config::PARTNER_ID); $client->setKs($ks); } catch (Exception $ex) { $this->assertTrue(false, 'Exception in session->start - ' . $ex->getMessage()); } $this->client = $client; }
/** * Init a KalturaClient object for the target account * @param KalturaCrossKalturaDistributionProfile $distributionProfile * @throws Exception */ protected function initClients(KalturaCrossKalturaDistributionProfile $distributionProfile) { // init source client $sourceClientConfig = new KalturaConfiguration($distributionProfile->partnerId); $sourceClientConfig->serviceUrl = KBatchBase::$kClient->getConfig()->serviceUrl; // copy from static batch client $sourceClientConfig->setLogger($this); $this->sourceClient = new KalturaClient($sourceClientConfig); $this->sourceClient->setKs(KBatchBase::$kClient->getKs()); // copy from static batch client // init target client $targetClientConfig = new KalturaConfiguration($distributionProfile->targetAccountId); $targetClientConfig->serviceUrl = $distributionProfile->targetServiceUrl; $targetClientConfig->setLogger($this); $this->targetClient = new KalturaClient($targetClientConfig); $ks = $this->targetClient->user->loginByLoginId($distributionProfile->targetLoginId, $distributionProfile->targetLoginPassword, "", 86400, 'disableentitlement'); $this->targetClient->setKs($ks); }
/** * @param KSchedularTaskConfig $taskConfig */ public function __construct($taskConfig = null) { parent::__construct($taskConfig); KalturaLog::debug('This batch index: ' . $this->getIndex()); KalturaLog::debug('This session key: ' . $this->sessionKey); $this->kClientConfig = new KalturaConfiguration(); $this->kClientConfig->setLogger($this); $this->kClientConfig->serviceUrl = $this->taskConfig->getServiceUrl(); $this->kClientConfig->curlTimeout = $this->taskConfig->getCurlTimeout(); $this->kClientConfig->clientTag = 'batch: ' . $this->taskConfig->getSchedulerName(); $this->kClient = new KalturaClient($this->kClientConfig); //$ks = $this->kClient->session->start($secret, "user-2", KalturaSessionType::ADMIN); $ks = $this->createKS(); $this->kClient->setKs($ks); KDwhClient::setFileName($this->taskConfig->getDwhPath()); $this->onBatchUp(); KScheduleHelperManager::saveRunningBatch($this->taskConfig->getCommandsDir(), $this->getName(), $this->getIndex()); }
function startKalturaSession() { $kConfig = new KalturaConfiguration(PARTNER_ID); $kConfig->serviceUrl = kalturaServiceURL; $client = new KalturaClient($kConfig); writeToLog("startKalturaSession()"); $userID = "OVALAutomatedUploads"; // If this user does not exist in your KMC, then it will be created. //$sessionType = ($isAdmin)? KalturaSessionType::ADMIN : KalturaSessionType::USER; $sessionType = KalturaSessionType::ADMIN; try { $ks = $client->generateSession(ADMIN_SECRET, $userID, $sessionType, PARTNER_ID); $client->setKs($ks); } catch (Exception $ex) { writeToLog("could not start session - check configurations in KalturaTestConfiguration class"); } //writeToLog("client: " . print_r($client, true)); return $client; }
/** * Starts a new session * @param KalturaSessionType $type * @param string $userId */ protected function startSessionWithDiffe($type, $userId, $privileges = null) { $testConfig = $this->config->get('config'); $secret = $testConfig->secret; if ($type == SessionType::ADMIN) { $secret = $testConfig->userSecret; } if (is_null($privileges)) { $privileges = $testConfig->privilege; } $ks = $this->client->generateSession($secret, $userId, $type, $testConfig->partnerId, $testConfig->expiry, $privileges); KalturaLog::debug('Generate session for ks with privileges: ' . print_r($privileges, true) . ' ks: ' . $ks); if (!$ks) { return false; } $this->client->setKs($ks); KalturaLog::info("Session started [{$ks}]"); return true; }
/** * Helper function to generate the KS (kaltura session) * @param bool $admin - wether or not to use an admin session * @return KalturaClient */ function simplekaltura_create_client($admin = false) { // Get settings $partner_user_id = elgg_get_plugin_setting('kaltura_partnerid', 'simplekaltura'); //Construction of Kaltura objects for session initiation $config = simplekaltura_create_config(); $client = new KalturaClient($config); $partner = $client->partner->getSecrets($config->partnerId, elgg_get_plugin_setting('kaltura_email_account', 'simplekaltura'), elgg_get_plugin_setting('kaltura_password_account', 'simplekaltura')); if ($admin) { $st = KalturaSessionType::ADMIN; $secret = $partner->adminSecret; } else { $st = KalturaSessionType::USER; $secret = $partner->secret; } $ks = $client->session->start($secret, $partner_user_id, $st); // Set KS $client->setKs($ks); return $client; }
private function getClient() { if (!$this->initialized && !$this->client) { $this->initialized = true; try { $client = new KalturaClient($this->getConfig()); if ($session = $this->storedKey()) { $client->setKs($session); $this->client = $client; } elseif ($session = $this->initializeClient($client)) { $client->setKs($session); $this->client = $client; $this->storedKey($session); } } catch (Exception $e) { TikiLib::lib('errorreport')->report($e->getMessage()); } } return $this->client; }
protected function init($args) { parent::init($args); if (!isset($args['PartnerID'])) { throw new KurogoConfigurationException('Kaltura PartnerID not included'); } $this->token = $args['token']; if (!isset($args['PartnerSecret'])) { throw new KurogoConfigurationException('Kaltura PartnerSecret not included'); } define("KALTURA_PARTNER_ID", PartnerID); define("KALTURA_PARTNER_ADMIN_SECRET", PartnerSecret); //define session variables $this->partnerUserID = 'ANONYMOUS'; //construct Kaltura objects for session initiation $config = new KalturaConfiguration(KALTURA_PARTNER_ID); $client = new KalturaClient($config); $ks = $client->session->start(KALTURA_PARTNER_ADMIN_SECRET, $this->partnerUserID, KalturaSessionType::ADMIN); $client->setKs($ks); $this->setBaseURL("http://www.kaltura.com/api_v3"); }
public function doRecalculate(KalturaRecalculateResponseProfileCacheJobData $data) { $job = KJobHandlerWorker::getCurrentJob(); KBatchBase::impersonate($job->partnerId); $partner = KBatchBase::$kClient->partner->get($job->partnerId); KBatchBase::unimpersonate(); $role = reset($data->userRoles); /* @var $role KalturaIntegerValue */ $privileges = array('setrole:' . $role->value, 'disableentitlement'); $privileges = implode(',', $privileges); $client = new KalturaClient(KBatchBase::$kClientConfig); $ks = $client->generateSession($partner->adminSecret, 'batchUser', $data->ksType, $job->partnerId, 86400, $privileges); $client->setKs($ks); $options = new KalturaResponseProfileCacheRecalculateOptions(); $options->limit = $this->maxCacheObjectsPerRequest; $options->cachedObjectType = $data->cachedObjectType; $options->objectId = $data->objectId; $options->startObjectKey = $data->startObjectKey; $options->endObjectKey = $data->endObjectKey; $options->jobCreatedAt = $job->createdAt; $options->isFirstLoop = true; $recalculated = 0; try { do { $results = $client->responseProfile->recalculate($options); $recalculated += $results->recalculated; $options->startObjectKey = $results->lastObjectKey; $options->isFirstLoop = false; } while ($results->lastObjectKey); } catch (KalturaException $e) { if ($e->getCode() != self::RESPONSE_PROFILE_CACHE_ALREADY_RECALCULATED && $e->getCode() != self::RESPONSE_PROFILE_CACHE_RECALCULATE_RESTARTED) { throw $e; } KalturaLog::err($e); } return $recalculated; }
/** * Will take a single KalturaBatchJob and export the given file * * @param KalturaBatchJob $job * @param KalturaStorageExportJobData $data * @return KalturaBatchJob */ protected function export(KalturaBatchJob $job, KalturaStorageExportJobData $data) { KalturaLog::debug("export({$job->id})"); $srcFile = str_replace('//', '/', trim($data->srcFileSyncLocalPath)); $this->updateJob($job, "Syncing {$srcFile}, id: {$data->srcFileSyncId}", KalturaBatchJobStatus::QUEUED, 1); $remoteClientConfig = clone $this->kClient->getConfig(); $remoteClientConfig->serviceUrl = $data->serverUrl; $remoteClientConfig->curlTimeout = $this->taskConfig->maximumExecutionTime; $remoteClient = new KalturaClient($remoteClientConfig); $remoteClient->setKs($this->kClient->getKs()); try { $fileSync = $remoteClient->fileSync->sync($data->srcFileSyncId, realpath($srcFile)); if ($fileSync->status == KalturaFileSyncStatus::READY) { return $this->closeJob($job, null, null, null, KalturaBatchJobStatus::FINISHED); } return $this->closeJob($job, KalturaBatchJobErrorTypes::APP, 0, 'File sync not ready', KalturaBatchJobStatus::RETRY); } catch (KalturaException $kex) { return $this->closeJob($job, KalturaBatchJobErrorTypes::KALTURA_API, $kex->getCode(), "Error: " . $kex->getMessage(), KalturaBatchJobStatus::RETRY); } catch (KalturaClientException $kcex) { return $this->closeJob($job, KalturaBatchJobErrorTypes::KALTURA_CLIENT, $kcex->getCode(), "Error: " . $kcex->getMessage(), KalturaBatchJobStatus::RETRY); } catch (Exception $e) { return $this->closeJob($job, KalturaBatchJobErrorTypes::RUNTIME, $e->getCode(), $e->getMessage(), KalturaBatchJobStatus::FAILED); } }
/** * * @return KalturaClient */ public static function getClient() { if (self::$client) { return self::$client; } $partnerId = self::getPartnerId(); $ks = self::getKs(); $config = new KalturaConfiguration($partnerId); $config->serviceUrl = self::getServiceUrl(); $config->curlTimeout = self::getCurlTimeout(); $config->setLogger(new Kaltura_ClientLoggingProxy()); $front = Zend_Controller_Front::getInstance(); $bootstrap = $front->getParam('bootstrap'); if ($bootstrap) { $enviroment = $bootstrap->getApplication()->getEnvironment(); if ($enviroment === 'development') { $config->startZendDebuggerSession = true; } } $client = new KalturaClient($config); $client->setKs($ks); self::$client = $client; return $client; }
<?php //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
<?php //This script generates and saves a player in the account //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 'lib/php5/KalturaClient.php'; $config = new KalturaConfiguration($_REQUEST['partnerId']); $config->serviceUrl = 'http://www.kaltura.com/'; $client = new KalturaClient($config); $client->setKs($_REQUEST['session']); $choices = $_REQUEST['choices']; $buyFunction = $_REQUEST['buyFunction']; //If the user chose to have a new player generated, clone the old one if ($choices[4]) { $id = $client->uiConf->cloneAction($_REQUEST['player'])->id; } else { $id = $_REQUEST['player']; } //The custom flashVars are introduced based on the administrator's choices $uiConf = $client->uiConf->get($id); $xml = $uiConf->confFile; $xml2 = $uiConf->confFileFeatures; $dom = new DOMDocument(); $dom2 = new DOMDocument(); $dom->loadXML($xml); $dom2->loadXML($xml2); $xpath = new DOMXpath($dom); $xpath2 = new DOMXpath($dom2); $uiVarsNode = $xpath->query('/layout/uiVars')->item(0); $uiVarsNode2 = $xpath2->query('/snapshot/uiVars')->item(0);
function getClient($configObj) { require_once 'KalturaClient.php'; $kconf = new KalturaConfiguration($configObj->statics->partner_id); $kconf->serviceUrl = $configObj->statics->service_url; $kclient = new KalturaClient($kconf); $kclient->setKs($kclient->session->startLocal($configObj->statics->admin_secret, "", 2)); return $kclient; }
function getKalturaClient($isAdmin = false, $privileges = null) { // get the configuration to use the kaltura client $kalturaConfig = KalturaHelpers::getServiceConfiguration(); $sessionUser = KalturaHelpers::getSessionUser(); if (!$privileges) { $privileges = 'edit:*'; } // inititialize the kaltura client using the above configurations $kalturaClient = new KalturaClient($kalturaConfig); // get the current logged in user // $user = KalturaHelpers::getPlatformKey("user", ""); $user = $sessionUser->userId; if ($isAdmin) { $adminSecret = KalturaHelpers::getPlatformKey("admin_secret", ""); $ksId = $kalturaClient->session->start($adminSecret, $user, KalturaSessionType::ADMIN, -1, 86400, $privileges); } else { $secret = KalturaHelpers::getPlatformKey("secret", ""); $ksId = $kalturaClient->session->start($secret, $user, KalturaSessionType::USER, -1, 86400, $privileges); } $kalturaClient->setKs($ksId); return $kalturaClient; }
/** * * Adds the permissions for the test partner * @param $client - KalturaClient */ public static function addPermissions(KalturaClient $client) { $partnerId = $client->getConfig()->partnerId; //Get the admin partner id and secret from the application.ini $adminConsoleIniPath = KALTURA_ROOT_PATH . "/configurations/admin.ini"; $adminIni = new Zend_Config_Ini($adminConsoleIniPath); $adminProductionSettings = $adminIni->get('production'); $adminConsolePartnerId = $adminProductionSettings->settings->partnerId; $adminConsolePartnerSecret = $adminProductionSettings->settings->secret; $adminConfig = new KalturaConfiguration($adminConsolePartnerId); $adminConfig->serviceUrl = $client->getConfig()->serviceUrl; //The same service url of the test partner client $adminClient = new KalturaClient($adminConfig); //TODO: get this from the installation or outside input $ks = $adminClient->user->loginByLoginId('*****@*****.**', 'admin'); $adminClient->setKs($ks); $addedPermissions = array(); try { $addedPermissions[] = KalturaTestDeploymentHelper::createPermission("CUEPOINT_PLUGIN_PERMISSION", KalturaPermissionType::PLUGIN); $addedPermissions[] = KalturaTestDeploymentHelper::createPermission("CODECUEPOINT_PLUGIN_PERMISSION", KalturaPermissionType::PLUGIN); $addedPermissions[] = KalturaTestDeploymentHelper::createPermission("ADCUEPOINT_PLUGIN_PERMISSION", KalturaPermissionType::PLUGIN); $addedPermissions[] = KalturaTestDeploymentHelper::createPermission("ANNOTATION_PLUGIN_PERMISSION", KalturaPermissionType::PLUGIN); $addedPermissions[] = KalturaTestDeploymentHelper::createPermission("DROPFOLDER_PLUGIN_PERMISSION", KalturaPermissionType::PLUGIN); $addedPermissions[] = KalturaTestDeploymentHelper::createPermission("CONTENTDISTRIBUTION_PLUGIN_PERMISSION", KalturaPermissionType::PLUGIN); $addedPermissions[] = KalturaTestDeploymentHelper::createPermission("METADATA_PLUGIN_PERMISSION", KalturaPermissionType::PLUGIN); } catch (Exception $e) { print "Exception was raised during permission adding: " . $e->getMessage() . "\n"; } $systemPartnerPlugin = KalturaSystemPartnerClientPlugin::get($adminClient); $partner = $systemPartnerPlugin->systemPartner->get($partnerId); $partnerConfig = $systemPartnerPlugin->systemPartner->getConfiguration($partnerId); $partnerConfig->storageServePriority = KalturaStorageServePriority::KALTURA_ONLY; $newConfig = new KalturaSystemPartnerConfiguration(); foreach ($addedPermissions as $permission) { $newConfig->permissions[] = $permission; } if ($newConfig->permissions && count($newConfig->permissions)) { //Clean the id from the permissions foreach ($newConfig->permissions as &$permission) { $permission->id = null; $permission->partnerId = null; $permission->createdAt = null; $permission->updatedAt = null; $permission->status = KalturaPermissionStatus::ACTIVE; } } $result = $systemPartnerPlugin->systemPartner->updateConfiguration($partnerId, $newConfig); $config = new KalturaConfiguration(); $config->serviceUrl = $client->getConfig()->serviceUrl; $config->partnerId = self::$partner->id; $client = new KalturaClient($config); // create a client for the partner $ks = $client->session->start(self::$partner->adminSecret, null, KalturaSessionType::ADMIN, self::$partner->id, 86400, null); $client->setKs($ks); }
function getClient($partner_id, $admin_secret, $host) { require_once __DIR__ . '/KalturaClient.php'; $kconf = new KalturaConfiguration($partner_id); $kconf->serviceUrl = $host; $kclient = new KalturaClient($kconf); $kclient->setKs($kclient->session->startLocal($admin_secret, "", 2)); return $kclient; }
<?php require_once "../../config.php"; require_once 'lib.php'; try { $kClient = new KalturaClient(KalturaHelpers::getServiceConfiguration()); $kalturaUser = KalturaHelpers::getPlatformKey("user", ""); $kalturaSecret = KalturaHelpers::getPlatformKey("secret", ""); $ksId = $kClient->session->start($kalturaSecret, $kalturaUser, KalturaSessionType::USER); $kClient->setKs($ksId); $mix = new KalturaMixEntry(); // $mix -> name = "Editable video"; $mix->name = empty($_POST["name"]) ? "Editable video" : $_POST["name"]; $mix->editorType = KalturaEditorType::ADVANCED; $mix = $kClient->mixing->add($mix); $arrEntries = explode(',', $_POST['entries']); foreach ($arrEntries as $index => $entryId) { if (!empty($entryId)) { $kClient->mixing->appendMediaEntry($mix->id, $entryId); } } echo 'y:' . $mix->id; } catch (Exception $exp) { die('n:' . $exp->getMessage()); }