public function testUploadVideo() { $guid = Vzaar::uploadVideo(self::$filePath); $videoId = Vzaar::processVideo($guid, "for deletion", "php test", ""); $json = json_decode(Vzaar::deleteVideo($videoId)); $this->assertEquals($json->video_status_id, 9); }
public function testMulitpartVideoSignature() { $signature = Vzaar::getUploadSignature(null, true); $policy = base64_decode($signature['vzaar-api']['policy']); // has chunk and chunks policy $this->assertContains('["starts-with","$chunk",""]', $policy); $this->assertContains('["starts-with","$chunks",""]', $policy); }
public function testLinkUpload() { $title = "api-php-link-upload-" . generateRandomStr(5); $videoId = Vzaar::uploadLink(self::$fileUrl, $title); $vid = Vzaar::getVideoDetails($videoId, true); $this->assertEquals($vid->videoStatusDescription, "Preparing"); // clean up Vzaar::deleteVideo($videoId); }
public function testUploadVideo() { $title = "api-php-" . generateRandomStr(5); $guid = Vzaar::uploadVideo(self::$filePath); $videoId = Vzaar::processVideo($guid, $title, "php test", ""); $vid = Vzaar::getVideoDetails($videoId, true); $this->assertEquals($vid->videoStatusDescription, "Preparing"); // clean up Vzaar::deleteVideo($videoId); }
public function testEditVideo() { $videoId = API_ENVS::get()["user1"]["test_video_id"]; $newTitle = "api-php-" . generateRandomStr(7); $vid = Vzaar::getVideoDetails($videoId, true); $originalTitle = $vid->title; Vzaar::editVideo($videoId, $newTitle, "woof", false); $vid = Vzaar::getVideoDetails($videoId, true); $this->assertNotEquals($vid->title, $originalTitle); }
<?php require '../../src/Vzaar.php'; Vzaar::$token = 'u2nd3DVI71jQ7dTtz9mHA953XeIQeodmZvSE6AbTX8'; Vzaar::$secret = 'skitsanos'; $rawReply = Vzaar::getUploadSignature(); $api_reply = $rawReply['vzaar-api']; echo json_encode($api_reply);
<?php require_once '../src/Vzaar.php'; Vzaar::$token = "token"; Vzaar::$secret = "secret"; $req = Vzaar::setAuth('https://vzaar.com/api/test/whoami.json'); header('Content-type: text/plain'); echo $req->to_header();
?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>SWFUpload Demos</title> <link href="http://demo.swfupload.org/v220/css/default.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script> <script type="text/javascript" src="swfupload.js"></script> <script type="text/javascript" src="swfupload.queue.js"></script> <script type="text/javascript" src="fileprogress.js"></script> <script type="text/javascript" src="handlers.js"></script> <script type="text/javascript"> var vzaar_signature = <?php echo json_encode(Vzaar::getUploadSignature()); ?> ; var swfu; var s3Response = {}; $(function () { var settings = { flash_url:"swfupload.swf", upload_url:'http://' + vzaar_signature["vzaar-api"].bucket + '.s3.amazonaws.com/', post_params:{ "content-type":"binary/octet-stream", "acl":vzaar_signature["vzaar-api"].acl, "policy":vzaar_signature["vzaar-api"].policy, "AWSAccessKeyId":vzaar_signature["vzaar-api"].accesskeyid,
/** * @static * @param $guid * @param $title * @param $description * @param $labels * @param int $width * @param int $bitrate * @param bool $transcoding * @param string $replace * @return mixed */ public static function processVideoCustomized($guid, $title, $description, $labels, $width = 200, $bitrate = 256, $transcoding = false, $replace = '') { $_url = self::$url . "api/videos"; if ($replace != '') { $replace = '<replace_id>' . $replace . '</replace_id>'; } $req = Vzaar::setAuth($_url, 'POST'); $data = '<vzaar-api> <video>' . $replace . ' <guid>' . $guid . '</guid> <title>' . $title . '</title> <description>' . $description . '</description> <labels>' . $labels . '</labels> <profile>' . Profile::Custom . '</profile> <encoding> <width>' . $width . '</width> <bitrate>' . $bitrate . '</bitrate> </encoding>'; if ($transcoding) { $data .= '<transcoding>true</transcoding>'; } $data .= '</video> </vzaar-api>'; $c = new HttpRequest($_url); $c->verbose = Vzaar::$enableHttpVerbose; $c->method = 'POST'; array_push($c->headers, $req->to_header()); array_push($c->headers, 'User-Agent: Vzaar OAuth Client'); array_push($c->headers, 'Connection: close'); array_push($c->headers, 'Content-Type: application/xml'); $apireply = new XMLToArray($c->send($data)); return $apireply->_data[0]["vzaar-api"]["video"]; }
<?php require_once 'Vzaar.php'; Vzaar::$token = 'YurxlhhEDLkce4psktKGVIxooQlSDF7T4HUWdYp6ZQ'; // Vzaar::$secret = 'krevision'; $api_reply = Vzaar::getUploadSignature(); echo json_encode($api_reply['vzaar-api']);
<?php /* * @author Skitsanos */ require_once '../src/Vzaar.php'; Vzaar::$token = 'token'; // Vzaar::$secret = 'secret'; $filename = '548.mov'; // the file must be located in the same directory as the script. If not use full disk path $file = getcwd() . '\\' . $filename; echo 'file to upload: ' . $file; //$result=Vzaar::uploadVideo($file); $result = Vzaar::processVideo('guid', 'testing special characters like & so on', '', '', Profile::HighDefinition); echo $result;
public function testGenerateThumbnail() { $videoId = API_ENVS::get()["user1"]["test_video_id"]; $res = Vzaar::generateThumbnail($videoId, 2); $this->assertRegExp('/Accepted/', $res); }
<?php /* * S3_Upload Test * Generating Signature for Amazon S3 uploads. Add your own security layer here * if necessary. */ require_once '../../src/Vzaar.php'; Vzaar::$token = "u2nd3DVI71jQ7dTtz9mHA953XeIQeodmZvSE6AbTX8"; Vzaar::$secret = "skitsanos"; Vzaar::$enableFlashSupport = true; header('Content-type: text/xml'); echo Vzaar::getUploadSignatureAsXml();
<?php require_once '../../src/Vzaar.php'; Vzaar::$token = "u2nd3DVI71jQ7dTtz9mHA953XeIQeodmZvSE6AbTX8"; Vzaar::$secret = "skitsanos"; header('Content-type: text/html'); if (isset($_POST['guid'])) { $apireply = Vzaar::processVideoCustomized($_POST['guid'], $_POST['title'], $_POST['description'], ''); echo $apireply; } else { echo 'GUID is missing'; }
<?php require_once '../../src/Vzaar.php'; Vzaar::$token = "GETUGkPFNC84JlzXkOMSYQFTOCAixOIiroh7oUj3k"; Vzaar::$secret = "skitsanos"; $guid = Vzaar::uploadVideo('D:\\Sites\\Vzaar\\Vzaar API\\api\\php\\trunk\\tests\\video.flv'); echo 'guid: ' . $guid . ' --- video id: '; $apireply = Vzaar::processVideo($guid, 'SimpleUpload test', '', 1); echo $apireply;
<?php /* * @author Skitsanos */ require_once '../src/Vzaar.php'; /** * This API call returns the user's public details along with it's relevant metadata */ var_dump(Vzaar::getUserDetails('user'));
<?php /* * @author Skitsanos */ require_once '../src/Vzaar.php'; Vzaar::$token = 'token'; // Vzaar::$secret = 'secret'; $guid = ''; if (isset($_GET['guid'])) { $guid = $_GET['guid']; } if (isset($_POST['guid'])) { $apireply = Vzaar::processVideo($_POST['guid'], $_POST['title'], $_POST['description'], 1); } ?> <!DOCTYPE html> <html> <head> <title>Process video</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="author" content="Skitsanos.com"/> </head> <body> <?php print_r('Returned Video ID: ' . $apireply); ?> <form action="uploadvideoprocess.php" method="post"> <table cellspacing='0' cellpadding='0' border='0'>
public function testResponse() { $accountId = 34; $account = Vzaar::getAccountDetails($accountId); $this->assertEquals($account->accountId, $accountId); }
public function testResponse() { $username = API_ENVS::get()["user1"]["login"]; $user = Vzaar::getUserDetails($username); $this->assertEquals($username, $user->authorName); }
<?php date_default_timezone_set("Europe/London"); require_once '../src/Vzaar.php'; Vzaar::$token = "token"; Vzaar::$secret = "secret"; $title = "My video"; $description = "Sample description"; if (isset($_POST['url'])) { $video_id = Vzaar::uploadLink($_POST['url'], $title, $description); print "Video id: " . $video_id; } ?> <html> <head> <title>Link Upload Form</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> </head> <body> <form method="post" enctype="multipart/form-data"> URL to download the video from: <input name="url" type="text"/> <br/> <input type="submit" value="Upload Video"/> </form> </body> </html>
public function testUploadThumbnail() { $videoId = API_ENVS::get()["user1"]["test_video_id"]; $res = Vzaar::uploadThumbnail($videoId, self::$thumbPath); $this->assertRegExp('/Accepted/', $res); }
<?php require_once '../../src/Vzaar.php'; Vzaar::$token = "u2nd3DVI71jQ7dTtz9mHA953XeIQeodmZvSE6AbTX8s34"; Vzaar::$secret = "skitsanos"; header('Content-type: text/html'); if (isset($_POST['guid'])) { $apireply = Vzaar::processVideo($_POST['guid'], $_POST['title'], $_POST['description'], 's3_upload', Profile::Original); echo $apireply; } else { echo 'GUID is missing'; }
<?php /* * @author skitsanos */ require_once '../src/Vzaar.php'; Vzaar::$secret = 'YOUR_VZAAR_USERNAME'; Vzaar::$token = 'API_TOKEN'; if (isset($_GET['id'])) { $res = Vzaar::deleteVideo($_GET['id']); print_r($res); } ?> <form method='get'> Video Id: <input type='text' name='id' value='0'/> <input type='submit'/> </form>
<?php /* * @author Skitsanos */ require_once '../src/Vzaar.php'; Vzaar::$secret = 'secret'; Vzaar::$token = 'token'; if (isset($_GET['id'])) { $res = Vzaar::editVideo($_GET['id'], $_GET['title'], $_GET['description']); print_r($res); } ?> <form method='get'> Video Id: <input type='text' name='id' value='36213'/><br/> Title: <input type='text' name='title' value='New title'/><br/> Description: <input type='text' name='description' value='New description'/><br/> <input type='submit'/> </form>
<?php // Include the vzaar library require 'vzaar/src/Vzaar.php'; // Authenticate with vzaar using environmet variables Vzaar::$token = $_ENV['VZAAR_TOKEN']; Vzaar::$secret = $_ENV['VZAAR_SECRET'];
<?php date_default_timezone_set("Europe/London"); require_once '../src/Vzaar.php'; if (isset($_GET['secret']) && isset($_GET['token'])) { Vzaar::$token = $_GET['token']; Vzaar::$secret = $_GET['secret']; echo 'API reply: ' . Vzaar::whoAmI(); } else { echo 'Call whoAmI service as following: whoami.php?token=YOUR_API_TOKEN&secret=YOUR_VZAAR_USERNAME'; }
<?php /* * @author Skitsanos */ require_once '../src/Vzaar.php'; Vzaar::$token = 'token'; // Vzaar::$secret = 'secret'; $redirect_url = 'http://example.com'; $uploadSignature = Vzaar::getUploadSignature($redirect_url); $signature = $uploadSignature['vzaar-api']; ?> <html> <head> <title>S3 POST Form with redirect</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="author" content="Skitsanos.com"/> </head> <body> <form action="https://<?php echo $signature['bucket']; ?> .s3.amazonaws.com/" method="post" enctype="multipart/form-data"> <!-- <input name="content-type" type="hidden" value="binary/octet-stream" /> --> <input type="hidden" name="acl" value="<?php
public function testRenditions() { $videoId = API_ENVS::get()["user1"]["test_video_id"]; $vid = Vzaar::getVideoDetails($videoId, true); $this->assertEquals($vid->renditions[0]->statusId, 3); }
* * This PHP implementation been tested under Linux/Apache and Windows/IIS. */ require_once 'Vzaar.php'; require_once 'User.php'; require_once 'Video.php'; require_once 'VideoList.php'; require_once 'AccountType.php'; //require_once 'HttpRequest.php'; /** * This API call returns the user's public details along with it's relevant metadata */ Vzaar::$token = 'token'; // Vzaar::$secret = 'secret'; Vzaar::$enableHttpVerbose = false; date_default_timezone_set("Europe/London"); /** * Public API */ //var_dump(Vzaar::getVideoDetails(17069)); //var_dump(Vzaar::getVideoDetails(36356, true)); //var_dump(Vzaar::getAccountDetails(1)); //var_dump(Vzaar::getVideoList('vzaar-user', true, 10)); //var_dump(Vzaar::searchVideoList('vzaar-user', 'true', 's3')); //var_dump(Vzaar::getUserDetails('vzaar-user')); //var_dump(Vzaar::getVideoDetails(21791,true)); //var_dump(Vzaar::getUploadSignature()); //print_r(Vzaar::getUploadSignature()); //print_r(Vzaar::uploadSubtitle('en', 4699267, 'subtitle')); //print_r(Vzaar::getVideoDetails(632017, true));
<?php // common.php houses common setup and environment setup require "common.php"; // set the output type header, so that requesting clients are aware that the // response is JSON header("Content-Type: application/json"); // get a signature from vzaar and output it as JSON // setting the second parameter to true indicates that we are requesting a // multipart signature // echo(json_encode(Vzaar::getUploadSignature(null, true))); echo json_encode(Vzaar::getUploadSignature(null, $_GET['filename'], true, $_GET['filename'], $_GET['filesize']));