Skip to content

Instantly share code, notes, and snippets.

View zoharbabin's full-sized avatar
💭
dreaming, breaking, building

Zohar Babin zoharbabin

💭
dreaming, breaking, building
View GitHub Profile
@zoharbabin
zoharbabin / kaltura-captions-studio-embed.php
Created July 25, 2021 07:23
A quick embed code sample showing how to integrate the Kaltura Captions Editor in web apps via iframe embed
<?php
$partnerId = YOUR_KALTURA_ACCOUNT_ID; //https://kmc.kaltura.com/index.php/kmcng/settings/integrationSettings
$apiAdminSecret = 'YOUR_KALTURA_API_ADMIN_SECRET'; //https://kmc.kaltura.com/index.php/kmcng/settings/integrationSettings
$kalturaServiceUrl = 'https://www.kaltura.com';
//This goes on your backend - never include API secret keys in front end code
$sessionExpire = 60 * 60 * 24; //one day
$uniqueUserId = '[email protected]'; //Make sure this is set to your real user IDs so that Analytics and Entitlements will really be tracked according to your business needs
$entryId = 'YOUR_VIDEO_ID'; //The ID of the video entry whose caption asset you wish to edit. Get from media.list or https://kmc.kaltura.com/index.php/kmcng/content/entries/list
$assetId = null; //the ID of the caption Asset to edit. retrieved by captionAsset.list using the entry ID, formatIn="1,2" (SRT or DFXP) and statusEqual=2 (READY). If set to null, the first asset in the list response will be loaded by the editor.
$appName = 'myAppNam
@zoharbabin
zoharbabin / virtualEventAttendanceReports.php
Last active May 5, 2021 12:32
Example PHP code showing how to download Kaltura virtual event session attendance and add-to-calendar analytics reports as CSV files for sync with 3rd party BI systems
<?php
set_time_limit(0);
ini_set('memory_limit', '2048M');
error_reporting(E_ALL | E_STRICT);
ini_set('display_errors', 1);
date_default_timezone_set('Asia/Jerusalem'); // Make sure to set this to your desired timezone (https://www.php.net/manual/en/timezones.php)
const REPORT_SESSION_ATTENDANCE = 3009;
const REPORT_CERTIFICATE_OF_COMPLETION = 3010;
const REPORT_ADD_TO_CALENDAR = 3006;
@zoharbabin
zoharbabin / exportToCsvExample.php
Last active April 16, 2021 08:06
example of using baseEntry.exportToCsv action to get a full list of Kaltura entries as CSV emailed to you
// IMPORTANT: This action will EMAIL the CSV file to the email defined in the user's email field. Be sure to set userId in the KS that belongs to a user object that has email field properly set to a valid email address
//initialize kaltura
$kConfig = new KalturaConfiguration($pid);
$kConfig->setServiceUrl('https://www.kaltura.com');
$kConfig->setLogger($this);
$this->client = new KalturaClient($kConfig);
$this->ks = $this->client->session->start($secret, 'userIdToSendEmailWithCSV', SessionType::ADMIN, $pid, 86400, 'list:*,disableentitlement,*');
$this->client->setKs($this->ks);
This file has been truncated, but you can view the full file.
{
"basePath": "/api_v3",
"definitions": {
"KalturaABCScreenersWatermarkCondition": {
"allOf": [
{
"$ref": "#/definitions/KalturaCondition"
}
],
"properties": {},
#!/usr/bin/ruby
require 'kaltura'
include Kaltura
config = KalturaConfiguration.new()
config.service_url = 'https://www.kaltura.com'
client = KalturaClient.new(config);
parent_partner_id = # Your Kaltura Parent MultiAccount Partner ID (Kaltura Account ID)
login_id = #Your Kaltura Parent MultiAccount Admin Login Email
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
</head>
<body>
<input type="file" id="uploadfiles" accept="*.*" multiple />
<progress id="uploadprogress" style="display: none;" value="0" max="100"></progress>
<script>
resource = KalturaUrlResource()
resource.url = "https://www.youtube.com/watch?v=cPAbx5kgCJo"
result = client.media.addContent(entryId, resource)
resource = KalturaUploadedFileTokenResource()
resource.token = tokenId
mediaEntry = client.media.addContent(mediaEntry.id, resource)
fileData = open('IMG_9227.m4v', 'r')
result = client.uploadToken.upload(tokenId, fileData)
uploadToken = KalturaUploadToken()
result = client.uploadToken.add(uploadToken)
tokenId = result.id