I’m probably too easily impressed anytime a vendor shows me a web “playground” to experiment with their API, especially if it will generate code snippets for specific languages. IBM has a pretty neat tool for IBM Connections, but it requires too much setup/footprint in my opinion. Kaltura has something similar, but has the advantage of needing just a client library. I needed to get a list of owners and managers for channels in the KMS and it seemed like for a few calls, the test console could give me the basic code.
I started with JavaScript and ran into a lot of trouble, which I chalked up to my proxy for the request. I figured server-side Java would be a better choice since I wouldn’t have to deal with the cross-site scripting and it’s a language I know well. With the Kaltura API, you start by creating a “session” (also called a “ks” for Kaltura session). You can do this with your secret admin code, but it’s far better to do it with a user that has the privileges you need. I generated some of the basic code and pasted it into a runnable class.
Kaltura Generated Code
KalturaConfiguration config = new KalturaConfiguration();
config.setPartnerId(partnerId);
config.setEndpoint("https://www.kaltura.com/");
KalturaClient client = new KalturaClient(config);
String loginId = "userid";
String password = "password";
int partnerId = 999999;
int expiry = null;
String privileges = null;
Object result = client.getUserService().loginbyloginid(loginId, password, partnerId, expiry, privileges);
Immediately, I noticed some interesting things like assigning primitives to null and declaring variables after they are used, which are easily fixed, but the issues don’t end there. The return types are not usable (all objects) and the API calls don’t match the API you downloaded from the test application. Other code examples were worse-variables were declared when all that was needed was a simple assignment to something already created.
In hindsight, I expect it wasn’t my proxy or JavaScript skills, but similar code generation issues and API mismatches that were my downfall with JavaScript. My advice is to try the console to know what classes you’ll need and get a “hint” of what data is passed around-assume the code you get is just plain wrong. I posted my experience in the forums and the response was that Java isn’t as well supported as PHP and it’s just a guide to the type of code you might write. They have a developer site with code examples, but nothing in Java yet.
In case you were hoping to find some working sample code, I’ve attached code to create a session, get a list of categories, and print out all the users with manager access in case you’d find a complete code example useful.