示例#1
0
 /**
  * Get Upload Signature
  * @static
  * @param null $redirectUrl In case if you are using redirection after your upload, specify redirect URL
  * @return array
  */
 public static function getUploadSignature($redirectUrl = null)
 {
     $_url = self::$url . "api/videos/signature";
     if (Vzaar::$enableFlashSupport) {
         $_url .= '?flash_request=true';
     }
     if ($redirectUrl != null) {
         if (Vzaar::$enableFlashSupport) {
             $_url .= '&success_action_redirect=' . $redirectUrl;
         } else {
             $_url .= '?success_action_redirect=' . $redirectUrl;
         }
     }
     $req = Vzaar::setAuth($_url, 'GET');
     $req->verbose = Vzaar::$enableHttpVerbose;
     $c = new HttpRequest($_url);
     $c->method = 'GET';
     array_push($c->headers, $req->to_header());
     array_push($c->headers, 'User-Agent: Vzaar OAuth Client');
     return UploadSignature::fromXml($c->send());
 }
示例#2
0
 /**
  * Get Upload Signature
  * @static
  * @param null $redirectUrl In case if you are using redirection after your upload, specify redirect URL
  * @param false $multipart Initiate a multipart upload
  * @return array
  */
 public static function getUploadSignature($redirectUrl = null, $path, $multipart = false, $filename = null, $filesize = null)
 {
     if ($path == null) {
         throw new VzaarException('path/url could not be null');
     }
     if (!preg_match('/^(https?:\\/\\/+[\\w\\-]+\\.[\\w\\-]+)/i', $path)) {
         $_url = "path=" . $path;
         if ($filename != null) {
             $_url .= "&filename=" . $filename;
         }
         if ($filesize != null) {
             $_url .= "&filesize=" . $filesize;
         }
     } else {
         $_url .= "url=" . $path;
     }
     if (Vzaar::$enableFlashSupport) {
         $_url .= "&flash_request=true";
     }
     if ($redirectUrl != null) {
         $_url .= "&success_action_redirect=" . $redirectUrl;
     }
     if ($multipart) {
         $_url .= "&multipart=true";
         $_url .= "&uploader=" . Constants::Uploader;
     }
     $_base_url = self::$url . "api/v1.1/videos/signature?";
     $_auth_url = $_base_url . $_url;
     $_http_url = $_base_url . str_replace(' ', '+', $_url);
     $req = Vzaar::setAuth($_auth_url, 'GET');
     $req->verbose = Vzaar::$enableHttpVerbose;
     $c = new HttpRequest($_http_url);
     $c->method = 'GET';
     array_push($c->headers, $req->to_header());
     array_push($c->headers, 'User-Agent: Vzaar OAuth Client');
     $data = $c->send();
     return UploadSignature::fromXml($data);
 }