Need node.js sample to connect and get media listing

I am newbie. Please provide code sample to connect to Kaltura and get media listing in account for Node.js. I always see client object is undefined in my code. I masked user id.

 var cb = function (success, results){
    console.info(results);
};

var kc = require('../lib/kaltura/KalturaClient');
var ktypes = require('../lib/kaltura/KalturaTypes');

var partnerId = 1111111;
var conf = new kc.KalturaConfiguration(partnerId);
conf.serviceUrl = "http://www.kaltura.com";

var client = new kc.KalturaClient(conf);


var secret = "XXXXXXXXX";
var userId = "XXXX@XXXXX.com";
var type = ktypes.KalturaSessionType.ADMIN;

var expiry = 100000;
var privileges = null;
var result = client.session.start(cb, secret, userId, type, partnerId, expiry, privileges);

Hello,

First, can you check the /opt/kaltura/log/kaltura_api_v3.log for errors?
Second, can you try to create a session using the test console module? it is under the ‘developer’ tab in the admin console.

It displayed this string in console. djJ8MTgyMDk0MXx3MMvcMRJFGcDALif_CPaHOmLEaq1ZPDjB2GZpYx5rrXT0M8UCWSlQzAIdzYMv0nLhKB2ovo-VY-zD4lIXOYZKd55c1TTWzrOWkvq5YmU4puAc4u-sX4VUCP_TPurrZR4=0.00040292739868164

Does this mean call successful for session?

I am working on mac. which directory will have log file?

Appreciate for help.

Yes, this means it was successful.
The log is on the server side.

It works fine in console. but not via Node.js code above. Any links to Node.js code samples?

I really appreciate for help.

Hi,

You problem is here:
‘var cb = function (success, results){’

This is true for JS but the signature in NodeJS is only with ‘results’

Please try the following:

var cb = function (results){
if(results){
console.log(results);
return;
}

 handleResults(results);

};

var kc = require(’./KalturaClient’);
var ktypes = require(’./KalturaTypes’);

var partnerId = ;
var secret = ‘’;
var conf = new kc.KalturaConfiguration(partnerId);
conf.serviceUrl = “http://www.kaltura.com/”;

var client = new kc.KalturaClient(conf);
var userId=null;

var type = ktypes.KalturaSessionType.ADMIN;

var expiry = null;
var privileges = null;
//console.log(client);
var result = client.session.start(cb, secret, userId, type, partnerId, expiry, privileges);

Thank you. I was able to get all data fine two days ago. I am all good. Thank you. Yes I made the change similar to get it work.

I am trying the same - however getting toParams not set … I am using nodejs version 4.2.2 with express v4.13.1

Hi @avrono, please look at my answer at Need node.js sample to connect and get media listing, lets try to keep the discussion to one thread since its about the same issue.

1 Like