This integration guide assumes the use of Kaltura components at the following versions:
- api_v3 (aka Kaltura Partner Services 3.0)
- PHP KCL api_v3
Usage
This guide will show you how to create an RSS feed from media entries on Kaltura based on metadata and tags. Please note that Kaltura produces MRSS feeds from playlists and lists by default without additional development. Read about it at the bottom of the page.
Integration Steps
Step 1 and Step 2 should be reviewed if you haven't already integrated your web application with the Kaltura API.
Please make sure you review these sections as well as the related FAQ before starting your integration project.
Spending a moment to read this now may save you hours during your integration project.
- Step 1 - Obtain Partner Identifiers.
- Step 2 - Prepare your web application environment.
Full Example Script
The following example of PHP/JavaScript script demonstrates the integration of the KCW widget into a PHP based web application.
To run this script, please make sure you set your partner identifiers at the KALTURA_PARTNER_ID and KALTURA_PARTNER_ADMIN_SECRET constants.
Look for detailed information on this example at the following sections:
// include the Kaltura API Client Library
require_once("KalturaClient.php");
//define constants
define("KALTURA_PARTNER_ID", Your Kaltura PArtner ID);
define("KALTURA_PARTNER_ADMIN_SECRET", "Your Kaltura Admin Secret");
//define session variables
$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, $partnerUserID, KalturaSessionType::ADMIN);
$client->setKs($ks);
//define listing filter veriables
$pager = new KalturaFilterPager();
$pager->pageIndex = "1";
$pager->pageSize = "30";
$tag = "";
$filter = new KalturaMediaEntryFilter();
$filter->tagsAdminTagsMultiLikeOr = $tag; // The listing will retrieve content with this ADMIN-TAGS. You can change the filter however you like
$filter->orderBy = CREATED_AT_DESC;
// retrieve the information from Kaltura and construct the RSS
$entries = $client->media->listAction($filter, $pager);
if (!$entries)
{
$entries = array();
}
echo '<?xml version="1.0" encoding="ISO-8859-1" ?>';
echo '<rss version="2.0">';
?>
<channel>
<title>The Title of Your RSS Feed</title>
<link>http://www.yoursite.com</link>
<description>The Description of Your RSS Feed</description>
<?
foreach ($entries->objects as $entry)
{
?>
<item>
<title><? echo $entry->name.' ('.$entry->duration.' sec)'; ?></title>
<!-- in order for the link below to lead directly to that video you need to
accept the entry ID via GET in the page and pass to the player -->
<link>http://www.yoursite.com/videos.php?video=<? echo $entry->id; ?></link>
<description><? echo $entry->description; ?></description>
</item>
<?
}
?>
</channel>
</rss>
Include the Kaltura Client
The KalturaClient.php script is part of the PHP Kaltura API Client Library being included to enable the use of Kaltura objects.
The client should be available from within the web application after proper preparation for integration.
require_once("KalturaClient.php");
Define constants and variables
In the example lines above, the PHP code defines 2 constants and one variable, later to be used within implementation.
| Parameter | Data Type | Default Value | Description |
|---|---|---|---|
| KALTURA_PARTNER_ID | Numeric | N/A | Here you should put your Partner ID. Please refer to the How to Obtain Partner Identifiers page for reference. |
| KALTURA_PARTNER_ADMIN_SECRET | String | N/A | Here you should put your Web Admin Secret. Please refer to the How to Obtain Partner Identifiers page for reference. This example uses an admin KS to list content cross-partner regardless of the content owner-user. To generate an RSS feed per-user or if all of your content was uploaded by the same user ID you can use a web services KS instead. |
| partnerUserID | String | "ANONYMOUS" | Here you are able to populate your internal system end-user identifier. This is not relevant for producing a public RSS field - but is required to start a Kaltura session. |
Construct Kaltura objects for session initiation
$client = new KalturaClient($config);
$ks = $client->session->start(KALTURA_PARTNER_ADMIN_SECRET, $partnerUserID, KalturaSessionType::ADMIN);
$client->setKs($ks); // sets the KS to the client for future API calls
In the example lines above, the PHP code constructs the relevant Kaltura objects, used for session initiation. The objects are constructed as defined and implemented at the relevant Kaltura API Client Library. A unique session (KS) is then generated and set.
Media entries list retrieval
$pager = new KalturaFilterPager();
$pager->pageIndex = "1";
$pager->pageSize = "30";
//$tag = "";
$filter = new KalturaMediaEntryFilter();
$filter->tagsAdminTagsMultiLikeOr = $tag; // The listing will retrieve content with this ADMIN-TAGS. You can change the filter however you like
$filter->orderBy = CREATED_AT_DESC;
$entries = $client->media->listAction($filter, $pager);
In the example lines above, the PHP code constructs a filter object and a pager object for controlling the selection of media elements to be displayed within the RSS layout. These objects are passed as arguments to the Kaltura media:list service for setting the proper selection criteria.
The KalturaMediaEntryFilter object allows specific filters to apply on media selection and order. The filter parameters set in the example are only a few of the possible sets of filter parameters. A full list of filter parameters is available at the KalturaMediaEntryFilter page within the Kaltura API documentation site.
The KalturaFilterPager object enables paging management while retrieving media elements. This is an optional mechanism which may be in use when RSS feed is limited to X objects. When no pager object is passed as an argument to the Kaltura media:list service, the returned list will include all media items (according to filter object only). Look for more information on this object in the KalturaFilterPager page within the Kaltura API documentation site.
The Kaltura media:list service, returns a KalturaMediaListResponse Object. This is an array of KalturaMediaEntry objects, holding information on the entries to be presented within the Gallery implementation. The common parameters to be used within a gallery implementation are: thumbnailUrl, mediaType, id, name and description. Look for more information on these parameters at the KalturaMediaEntry page within the Kaltura API documentation site
Construct the RSS
{
$entries = array();
}
echo '<?xml version="1.0" encoding="ISO-8859-1" ?>';
echo '<rss version="2.0">';
?>
<channel>
<title>The Title of Your RSS Feed</title>
<link>http://www.yoursite.com</link>
<description>The Description of Your RSS Feed</description>
<?
foreach ($entries->objects as $entry)
{
?>
<item>
<title><? echo $entry->name.' ('.$entry->duration.' sec)'; ?></title>
<!-- in order for the link below to lead directly to that video you need to
accept the entry ID via GET in the page and pass to the player -->
<link>http://www.yoursite.com/videos.php?video=<? echo $entry->id; ?></link>
<description><? echo $entry->description; ?></description>
</item>
<?
}
?>
</channel>
</rss>
In the example above the actual RSS file is constructed from the information received in the listEntries. each entry creates an RSS item, using name, duration, description and entry Id. Note that in order for the link to lead directly to that video you need to accept the entry ID via GET in the page and pass to the player.
Built-in Kaltura MRSS Feed
The guide above explains how to generate an RSS feed from your content on Kaltura however already comes built-in with MRSS (Media RSS) format support for playlists. To receive an MRSS feed place your playlist ID in this URL
Filters can be passed to the playlist or listEntries in the URL itself. Complete List of filters is available in the API documentation.



