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);
 }
Esempio n. 2
0
 /**
  * Uploading a video from a url.
  *
  * @param string $url
  * @param string $title the title for the video
  * @param string $description the description for the video
  * @param int|\Profile $profile the size for the video to be encoded, if not specified it will use the vzaar default
  * @param int $bitrate the bitrate for the video to be encoded
  * @param int $width the width for the video to be encoded
  * @param int $replace_id an existing video id to be replaced with the new video
  * @param boolean $transcoding if true forces vzaar to transcode the video, false will use the original source file (only for mp4 and flv files)
  *
  * @return int $video_id returns the video id
  */
 public static function uploadLink($url, $title = NULL, $description = NULL, $profile = Profile::Medium, $bitrate = 256, $width = 200, $replace_id = NULL, $transcoding = false)
 {
     $_url = self::$url . "api/upload/link.xml";
     $signature = Vzaar::getUploadSignature();
     $req = Vzaar::setAuth($_url, 'POST');
     $data = '<?xml version="1.0" encoding="UTF-8"?>
             <vzaar-api>
                 <link_upload>
                     <key>' . $signature['vzaar-api']['key'] . '</key>
                     <guid>' . $signature['vzaar-api']['guid'] . '</guid>
                     <url>' . urlencode($url) . '</url>
                     <encoding_params>
                       <title>' . self::_sanitize_str($title) . '</title>
                       <description>' . self::_sanitize_str($description) . '</description>
                       <size_id>' . $profile . '</size_id>
                       <bitrate>' . $bitrate . '</bitrate>
                       <width>' . $width . '</width>
                       <replace_id>' . $replace_id . '</replace_id>
                       <transcoding>' . $transcoding . '</transcoding>
                     </encoding_params>
                 </link_upload>
             </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');
     $reply = $c->send($data);
     $xmlObj = new XMLToArray($reply);
     $arr = $xmlObj->getArray();
     $video_id = $arr['vzaar-api'] ? $arr['vzaar-api']['id'] : false;
     return $video_id;
 }
Esempio n. 3
0
<?php

require_once 'Vzaar.php';
Vzaar::$token = 'YurxlhhEDLkce4psktKGVIxooQlSDF7T4HUWdYp6ZQ';
//
Vzaar::$secret = 'krevision';
$api_reply = Vzaar::getUploadSignature();
echo json_encode($api_reply['vzaar-api']);
<?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

/*
 * @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 
Esempio n. 6
0
?>
<!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,
<?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']));
<?php

/*
 * @author Skitsanos
*/
date_default_timezone_set("Europe/London");
require_once '../src/Vzaar.php';
Vzaar::$token = 'token';
//
Vzaar::$secret = 'secret';
$uploadSignature = Vzaar::getUploadSignature();
$signature = $uploadSignature['vzaar-api'];
?>


<html>
    <head>
        <title>S3 POST Form</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 type="hidden" name="key" value="<?php 
echo $signature['key'];
?>
">