Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
php-api-examples/SampleUpLoadFile.php
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
49 lines (35 sloc)
1.5 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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>'; | |
?> |