本文整理汇总了PHP中KalturaClient::setKs方法的典型用法代码示例。如果您正苦于以下问题:PHP KalturaClient::setKs方法的具体用法?PHP KalturaClient::setKs怎么用?PHP KalturaClient::setKs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KalturaClient
的用法示例。
在下文中一共展示了KalturaClient::setKs方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getPlayList
function getPlayList()
{
// Your Kaltura partner credentials
define("PARTNER_ID", "xxxxxxx");
define("ADMIN_SECRET", "xxxxxxx");
$user = "SomeoneWeKnow";
$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;
}
示例2: getClient
/**
* 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;
}
示例3: get_se_wizard
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;
}
}
示例4: generate_ks
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;
}
示例5: isPayItem
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;
}
}
示例6: establishConnection
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;
}
示例7: startSession2
/**
* 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;
}
示例8: getSessionOnce
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;
}
示例9: getAPIObject
/**
*
* 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;
}
示例10: __construct
/**
* @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());
}
示例11: getKalturaClient
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;
}
示例12: getKalturaClient
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;
}
示例13: initClient
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;
}
示例14: initClients
/**
* 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);
}
示例15: __construct
/**
* @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());
}