listMyEntries call bugged?

3 replies [Last post]
Joined: 05/14/2009
Points: 7

Is it me or the following code is not returning the expected results? I was thinking that this was going to returned a list of entries for the user. In any case, most of the functions I have tried from the code I downloaded below, returned the same MISSING_KS error.

http://corp.kaltura.com/clients/ps2/kaltura-php5-client.zip
kaltura_client.php

Function

public function listMyEntries(KalturaSessionUser $kalturaSessionUser, KalturaEntryFilter $filter, $detailed = null, $pageSize = 10, $page = 1, $useFilterPuserId = null)
        {
                $params = array();

etc......

Function Called

$filter = new KalturaEntryFilter();
$test = $client->listMyEntries($user, $filter, '', 10, 1, '');

Error returned

code MISSING_KS
desc Missing KS. Session not established

Changed Function

public function listMyEntries(KalturaSessionUser $kalturaSessionUser, $kalturaSession, KalturaEntryFilter $filter, $detailed = null, $pageSize = 10, $page = 1, $useFilterPuserId = null)
        {
                $params = array();
                $params["ks"] = $kalturaSession;

etc .....

Function Called

$filter = new KalturaEntryFilter();
$test = $client->listMyEntries($user, $ks, $filter, '', 10, 1, '');

Results returned

page_size 10
page 1
user Array
serverTime 1242309138

Results for User Array

puserName Max
partnerId 27607
puserId 1
kuserId 469154
createdAt 2009-05-13 17:04:07
Joined: 01/05/2009
Points: 1697

Did you put your partner details ?

Try the following page (place this page in the same directory as "kaltura_client.php"):

<?php
require_once("kaltura_client.php");

$your_partner_id = "the partner id you recieved when registering";
$your_sub_partner_id = "any id you choose as sub partner (to identify applictions or sites)";
$username = "any user name";
$secert = 'the secret key you got when registering';

$conf = new KalturaConfiguration($your_partner_id, $your_sub_partner_id);
$user = new KalturaSessionUser($username);
$cl = new KalturaClient($conf);

//start function is a wrapper for startsession, it creates a new session and keep the ks in the client.
$result = $cl->start($user, $secert);

print_r($result);
?>

After filling in your partner details (see the inline comments) this will print out the KS result and then you can use the rest of the APIs.

In your changes you added a ks variable, but this is already being passed inside the $kalturaSessionUser after initializing, using the start method will create the ks and keep it inside the client.

Joined: 05/14/2009
Points: 7

Actually, I was just not initializing the KS session correctly.

After I addedd the following right after creating the client everything worked. I still don't understand the results but Ill keep reading the docs for now.

$result = $client->startSession($user, KALTURA_SECRET, false);
$ks = $result["result"]["ks"];

This is what I was not setting...

$client->setKs($ks);
Joined: 01/05/2009
Points: 1697

Well, this is another way of doing it.
If you'd like the client to do it for you, just use the 'start' method instead of 'startSession'.

What this code is doing is basically creating a new session with the Kaltura Server (to authenticate the user) and keep the ks (session) inside the client so that all later requests will use it (instead of you manually passing the ks in for every method).