Unable to get Kaltura Developer "Upload a Video" code to work - PHP

Good morning everyone. I’m currently working as a student worker at the University that I’m attending and I’ve been given a project. We are wanting to upload videos to our Kaltura library but I’m hitting a wall. I’ve been looking at the php files that are provided by Kaltura using the Kaltura Developer tool but I can’t get it to actually upload. I’m able to choose a file to upload but when I click the “Upload” button it does nothing. I have everything going through my www folder using WAMP.

I’m pretty green when it comes to PHP and using WAMP so I thought I’d see if I could get some pointers through this forum.

https://developer.kaltura.org/recipes/upload

Thanks,

Josh

Hi Josh,

Not sure I understand. You mentioned https://developer.kaltura.org/recipes/upload, does the upload work for you when trying it from this I/F and doesn’t when running the sample code locally from your own Windows machine?
If that is the case, start by looking at the Apache error logs and paste the errors you are seeing, if it does not work directly from https://developer.kaltura.org/recipes/upload either, please open the browser’s dev tools and look at the “console” tab for errors.

Also, try using this CLI script from your Windows machine and see if that works well:


You can use PHP CLI to run it from your cmd.exe.

Hey Jess, thanks for the advice. I’ve looked through the logs within Apache and there doesn’t seem to be any errors but I’ll post it anyway.

Jan 08 09:12:37.265597 2016] [mpm_winnt:notice] [pid 7916:tid 392] AH00455: Apache/2.4.9 (Win64) PHP/5.5.12 configured – resuming normal operations
[Fri Jan 08 09:12:37.265597 2016] [mpm_winnt:notice] [pid 7916:tid 392] AH00456: Apache Lounge VC11 Server built: Mar 16 2014 12:42:59
[Fri Jan 08 09:12:37.265597 2016] [core:notice] [pid 7916:tid 392] AH00094: Command line: ‘c:\wamp\bin\apache\apache2.4.9\bin\httpd.exe -d C:/wamp/bin/apache/apache2.4.9’
[Fri Jan 08 09:12:37.265597 2016] [mpm_winnt:notice] [pid 7916:tid 392] AH00418: Parent: Created child process 5716
[Fri Jan 08 09:12:37.757597 2016] [mpm_winnt:notice] [pid 5716:tid 308] AH00354: Child: Starting 64 worker threads.

As far as the CLI script goes, I’ve tried it but I’m getting some errors and I think it has to do with the two following lines within the script:

$entry_queue=’/tmp/upload_test_queue’;
require_once($basedir.’/create_session.php’);

Should I be setting $entry_queue to the path of the video I’d like to upload? I figured argument 4 would cover this?

Should create_session.php use the following code or could I get by with putting it in the actual script and bypass the call to create_session.php?

$result = $client->session->start($secret, $userId, $type, $partnerId, $expiry, $privileges);

Also, I’m getting an undefined function error with generate_ks() on line: $client=generate_ks($service_url,$partnerId,$secret,$type=KalturaSessionType::USER,$userId=null);
Is generate_ks() a place holder for something or should it work?

Thanks again for the help!

Hello,

Remove:

$entry_queue='/tmp/upload_test_queue';

create_session.php can be taken from https://github.com/kaltura/platform-install-packages/blob/Kajam-11.6.0/RPM/scripts/postinst/create_session.php

Give it a go and lets see what happens…

Jess,

I’ve made the changes that you suggested and now I’m getting the following error:

Fatal error: Uncaught exception ‘KalturaClientException’ with message ‘Uploading files is not supported with stream context http request, please use curl.’ in c:\wamp\www\Kaltura\lib\KalturaClientBase.php:570

I did some searching through Google and found where to enable the php_curl extention through WAMP and it is currently turned on.

Once again I REALLY appreciate the help. I feel I’m in over my head with this project.

Hi Josh,

You’re welcome.

Lets start by making sure you are using the clientlibs from here:
https://github.com/kaltura/KalturaGeneratedAPIClientsPHP/archive/11.5.0.zip

I have a feeling you are using an older version. Please update to this one and reshare the output you are getting.
Also, IMHO, it will be easier for you to develop from Linux, and it will certainly be easier for me to instruct you if you do:)

You can install a VM on your machine, using any common virtualization solution you’d like, instructions on how to use Vagrant are here:

1 Like

Jess,

Ok so I’ve moved all of my files along with the clientlibs over to a Linux box and I’m now getting the following error:

PHP Fatal error: Uncaught exception ‘KalturaClientException’ with message ‘failed to unserialize server result’ in /var/www/Wilson/Kaltura/lib/KalturaClientBase.php:401

Below is a copied output of the curl -V information incase it might be needed?

curl 7.35.0 (x86_64-pc-linux-gnu) libcurl/7.35.0 OpenSSL/1.0.1f zlib/1.2.8 libidn/1.28 librtmp/2.3
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtmp rtsp smtp smtps telnet tftp
Features: AsynchDNS GSS-Negotiate IDN IPv6 Largefile NTLM NTLM_WB SSL libz TLS-SRP

Any ideas?

Hello,

Are you working against SaaS or your own instance of Kaltura CE? If the later, you need to look at the logs under /opt/kaltura/log/kaltura_api_v3.log and find the actual error. If against SaaS, what PHP version are you using? Are you sure your account is in working order? are you able to upload to it using developer.kaltura.org/upload?

Jess,

From what I’ve been told we have the SaaS edition.

PHP Version:

PHP 5.5.9-1ubuntu4.14 (cli) (built: Oct 28 2015 01:34:46)
Copyright © 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright © 1998-2014 Zend Technologies
with Zend OPcache v7.0.3, Copyright © 1999-2014, by Zend Technologies

I believe the account is working correctly. If I go through the developer.kaltura.org/upload guide it works correctly using the embedded upload tool.

Jess,

Good news, I believe I got it! It turns out the information I was passing through was ADMIN information and since the KalturaSessionType was set for USER credentials it was causing problems. Once I change the KalturaSessionType to be ADMIN it went right through.

Thanks for ALL of the help.

Most welcome, glad you’re good.