-
Notifications
You must be signed in to change notification settings - Fork 7
/
SampleUpLoadFile.php
49 lines (35 loc) · 1.5 KB
/
SampleUpLoadFile.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
// Upload a file to the KMC
// Your Kaltura partner credentials
define("PARTNER_ID", "nnnnnn");
define("ADMIN_SECRET", "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
define("USER_SECRET", "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
require_once "KalturaClient.php";
$user = "SomeoneWeKnow"; // If this user does not exist in your KMC, then it will be created.
$kconf = new KalturaConfiguration(PARTNER_ID);
// If you want to use the API against your self-hosted CE,
// go to your KMC and look at Settings -> Integration Settings to find your partner credentials
// and add them above. Then insert the domain name of your CE below.
// $kconf->serviceUrl = "http://www.mySelfHostedCEsite.com/";
$kclient = new KalturaClient($kconf);
$ksession = $kclient->session->start(ADMIN_SECRET, $user, KalturaSessionType::ADMIN, PARTNER_ID);
if (!isset($ksession)) {
die("Could not establish Kaltura session. Please verify that you are using valid Kaltura partner credentials.");
}
$kclient->setKs($ksession);
// Set the response format
// KALTURA_SERVICE_FORMAT_JSON json
// KALTURA_SERVICE_FORMAT_XML xml
// KALTURA_SERVICE_FORMAT_PHP php
$kconf->format = KalturaClientBase::KALTURA_SERVICE_FORMAT_PHP;
$movie = "piano.m4v";
$token = $kclient->media->upload($movie);
$entry = new KalturaMediaEntry();
$entry->name = "Fun Piano";
$entry->mediaType = KalturaMediaType::VIDEO;
$result = $kclient->media->addFromUploadedFile($entry, $token);
echo '<h3>Media entry structure returned</h3>';
echo '<pre>';
print_r($result);
echo '</pre>';
?>