protected static function parametersToUrl($baseUrl, $params) { $params = self::parametersClean($params); $result = Vuzit_Service::getServiceUrl() . '/' . $baseUrl . "?"; foreach ($params as $key => &$val) { $result .= $key . '=' . rawurlencode($val) . '&'; } return $result; }
protected static function parametersToUrl($resource, $params, $id = null, $extension = 'xml') { $params = self::parametersClean($params); $result = Vuzit_Service::getServiceUrl() . "/" . $resource; if ($id != null) { $result .= "/" . $id; } $result .= "." . $extension . "?"; foreach ($params as $key => &$val) { $result .= $key . '=' . rawurlencode($val) . '&'; } return $result; }
function header_load($doc = null) { $id = ''; $onload = ''; if($doc != null) { $timestamp = time(); $id = $doc->getId(); $sig = Vuzit_Service::signature("show", $doc->getId(), $timestamp, get("p")); $onload = "initialize()"; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title>Vuzit <?php echo get("c") ?> Command Example</title> <link href="<?php echo Vuzit_Service::getServiceUrl(); ?>/stylesheets/Vuzit-2.9.css" rel="Stylesheet" type="text/css" /> <script src="<?php echo Vuzit_Service::getServiceUrl(); ?>/javascripts/Vuzit-2.9.js" type="text/javascript"></script> <script type="text/javascript"> // Called when the page is loaded. function initialize() { vuzit.Base.apiKeySet("<?php echo Vuzit_Service::getPublicKey(); ?>"); vuzit.Base.webServerSet({ host: '<?php echo domain(); ?>', port: '80' }); vuzit.Base.imageServerSet({ host: '<?php echo domain(); ?>', port: '80' }); var options = { signature: '<?php echo rawurlencode($sig); ?>', <?php if(get("p") != null) { ?> includedPages: '<?php echo get("p"); ?>', <?php } ?> timestamp: '<?php echo $timestamp ?>'} var viewer = vuzit.Viewer.fromId("<?php echo $id; ?>", options); viewer.display(document.getElementById("vuzit_viewer"), { zoom: 1 }); } </script> </head> <body onload="<?php echo $onload; ?>"> <h2>Command: <?php echo get("c"); ?></h2> <?php }
public static function upload($file, $options = null) { $params = self::postParameters("create", $options); if (!file_exists($file)) { throw new Vuzit_ClientException("Cannot find file at path: {$file}"); } $params['upload'] = "@" . $file; $params = self::parametersClean($params); $ch = self::curlRequest(); $url = Vuzit_Service::getServiceUrl() . "/documents.xml"; curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // only if expecting response curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST'); curl_setopt($ch, CURLOPT_POSTFIELDS, $params); // Setting the timeout to 5 minutes in case the file is large curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5 * 60 * 1000); $xml_string = curl_exec($ch); if (!$xml_string) { throw new Vuzit_ClientException('CURL load failed: "' . curl_error($ch) . '"'); } $info = curl_getinfo($ch); // TODO: This needs to be re-added some time in the future by looking at the // error codes. I would add it but they aren't documented. //if($info['http_code'] != 201) { // throw new Vuzit_ClientException("HTTP error, expected 201 but got: " . $info['http_code']); //} // Prevent the warnings if the XML is malformed $xml = @simplexml_load_string($xml_string); curl_close($ch); if (!$xml) { throw new Vuzit_ClientException("Error loading XML response"); } if ($xml->code) { throw new Vuzit_ClientException($xml->msg, (int) $xml->code); } if (!$xml->web_id) { throw new Vuzit_ClientException("Unknown error occurred"); } $result = new Vuzit_Document(); $result->id = (string) $xml->web_id; return $result; }