本文整理汇总了PHP中KalturaClient::generateSession方法的典型用法代码示例。如果您正苦于以下问题:PHP KalturaClient::generateSession方法的具体用法?PHP KalturaClient::generateSession怎么用?PHP KalturaClient::generateSession使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KalturaClient
的用法示例。
在下文中一共展示了KalturaClient::generateSession方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
}
示例2: 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;
}
示例3: 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;
}
示例4: startSessionWithDiffe
/**
* 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;
}
示例5: startKalturaSession
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;
}
示例6: doRecalculate
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;
}
示例7: KalturaConfiguration
<?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
示例8: KalturaConfiguration
<?php
require_once 'php5/KalturaClient.php';
$adminSecret = 'YOUR_KMC_ADMIN_SECRET';
//Your ADMIN API Secret from KMC>Settings>Integration Settings
$partnerId = 00;
//Your partner Id from KMC>Settings>Integration Settings
$userId = 'listentriestool';
$config = new KalturaConfiguration($partnerId);
$config->serviceUrl = 'http://www.kaltura.com';
$client = new KalturaClient($config);
$ks = $client->generateSession($adminSecret, $userId, KalturaSessionType::ADMIN, $partnerId);
$client->setKs($ks);
$filter = new KalturaMediaEntryFilter();
$filterAdvancedSearchItems = array();
$filterAdvancedSearchItems3 = new KalturaSearchCondition();
$filterAdvancedSearchItems3->field = "/*[local-name()='metadata']/*[local-name()='Tester']";
// Obtained by calling metadataProfile service and showing defined fields
$filterAdvancedSearchItems3->value = 'value2';
$filterAdvancedSearch = new KalturaMetadataSearchItem();
$filterAdvancedSearch->type = KalturaSearchOperatorType::SEARCH_OR;
$filterAdvancedSearch->metadataProfileId = 31;
// Obtained by calling metadataProfile service and getting the profile ID
$filterAdvancedSearch->items = array($filterAdvancedSearchItems3);
$filter->advancedSearch = $filterAdvancedSearch;
$results = $client->media->listAction($filter);
print '<pre>' . print_r($results, true) . '</pre>';
示例9: createKs
private function createKs(KalturaClient $client, KalturaScheduledTaskJobData $jobData)
{
$partnerId = self::$taskConfig->getPartnerId();
$sessionType = KalturaSessionType::ADMIN;
$puserId = 'batchUser';
$adminSecret = self::$taskConfig->getSecret();
$privileges = array('disableentitlement');
if ($jobData->referenceTime) {
$privileges[] = 'reftime:' . $jobData->referenceTime;
}
return $client->generateSession($adminSecret, $puserId, $sessionType, $partnerId, 86400, implode(',', $privileges));
}
示例10: log
$savePath = $argv[1];
}
class clientLogger implements IKalturaLogger
{
function log($msg)
{
echo "{$msg}\n";
}
}
$partnerId = 101;
$config = new KalturaConfiguration($partnerId);
$config->curlTimeout = 300;
$config->serviceUrl = 'http://kaltura.trunk';
$config->setLogger(new clientLogger());
$client = new KalturaClient($config);
$ks = $client->generateSession('815d617b032593a8519c4dcc5f61b25f', 'tester', KalturaSessionType::ADMIN, $partnerId);
$client->setKs($ks);
$filter = new KalturaAccessControlFilter();
$filter->orderBy = KalturaAccessControlOrderBy::CREATED_AT_ASC;
$pager = new KalturaFilterPager();
$pager->pageSize = 200;
$pager->pageIndex = 0;
$results = $client->accessControl->listAction($filter, $pager);
/* @var $results KalturaAccessControlListResponse */
while (count($results->objects)) {
echo count($results->objects) . "\n";
echo $results->totalCount . "\n";
if ($savePath) {
foreach ($results->objects as $object) {
echo "Saving: {$savePath}/{$object->id}.ser\n";
file_put_contents("{$savePath}/{$object->id}.ser", serialize($object));