<?php require_once 'test_include.php'; $doc = Vuzit_Document::findById($show_id); $timestamp = time(); $sig = Vuzit_Service::getSignature("show", $doc->getId(), $timestamp); ?> <!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 Show Example</title> <link href="http://vuzit.com/stylesheets/Vuzit-2.6.css" rel="Stylesheet" type="text/css" /> <script src="http://vuzit.com/javascripts/Vuzit-2.6.js" type="text/javascript"></script> <script type="text/javascript"> // Called when the page is loaded. function initialize() { vuzit.Base.apiKeySet("<?php echo Vuzit_Service::$PublicKey; ?> "); var options = {signature: '<?php echo rawurlencode($sig); ?> ', timestamp: '<?php echo $timestamp; ?>
<?php require_once 'test_include.php'; $doc = Vuzit_Document::upload("c:/temp/test.pdf", true); $timestamp = time(); $sig = Vuzit_Service::getSignature("show", $doc->getId(), $timestamp); ?> <!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> <title>Vuzit Upload Example</title> <link href="http://vuzit.com/stylesheets/Vuzit-2.6.css" rel="Stylesheet" type="text/css" /> <script src="http://vuzit.com/javascripts/Vuzit-2.6.js" type="text/javascript"></script> <script type="text/javascript"> // Called when the page is loaded. function initialize() { vuzit.Base.apiKeySet("<?php echo Vuzit_Service::$PublicKey; ?> "); var options = {signature: '<?php echo rawurlencode($sig); ?> ', timestamp: '<?php echo $timestamp; ?> ', ssl: true}
<?php require_once 'test_include.php'; if (isset($_GET["delete_id"])) { $message = "Document specified: " . $_GET["delete_id"]; try { $result = Vuzit_Document::destroy($_GET["delete_id"]); } catch (Vuzit_Exception $ex) { $result = false; $message = "Delete failed with code: " . $ex->getCode() . ", message: " . $ex->getMessage(); } } else { $message = null; } ?> <html> <head> <title>Delete test</title> </head> <body onload=""> <h2> <?php if ($message == null) { echo "No document specified"; } else { echo $message . "<br/>"; echo "Success?: " . ($result == true ? 'yes' : 'no'); } ?> </h2>
function upload_command() { $options = array(); if(get("p") != null) { $options["download_pdf"] = get("p"); } if(get("d") != null) { $options["download_document"] = get("d"); } if(get("s") != null) { $options["secure"] = get("s"); } $doc = Vuzit_Document::upload(get("path"), $options); header_load($doc); ?> <h3> Document - <?php echo $doc->getID(); ?> </h3> <?php echo printArray($options); ?> <div id="vuzit_viewer" style="width: 650px; height: 500px;"></div> <?php footer_load(); }
function search_command() { $options = array(); if (get("q") != null) { $options["query"] = get("q"); } if (get("l") != null) { $options["limit"] = get("l"); } if (get("o") != null) { $options["offset"] = get("o"); } if (get("O") != null) { $options["output"] = get("O"); } $docs = Vuzit_Document::findAll($options); header_load(); echo printArray($options); echo count($docs) . " documents found"; for ($i = 0; $i < count($docs); $i++) { $doc = $docs[$i]; ?> <h3> <?php echo $i + 1; ?> . Document - <?php echo $doc->getID(); ?> </h3> <?php if ($doc->getPageCount() != -1) { ?> <p>Results:</p> <ul> <li>Title: <?php echo $doc->getTitle(); ?> </li> <li>Page count: <?php echo $doc->getPageCount(); ?> </li> <li>File size: <?php echo $doc->getFileSize(); ?> </li> <li>Excerpt: <?php echo $doc->getExcerpt(); ?> ...</li> </ul> <?php } ?> <?php } footer_load(); }
public static function upload($file, $secure = true, $fileType = null) { $method = "create"; if ($file_type != null) { $params['file_type'] = $fileType; } $params['secure'] = $secure ? '1' : '0'; $params['upload'] = "@" . $file; $post_params = self::postParams($method, $params); $ch = curl_init(); $url = Vuzit_Service::$ServiceUrl . "/documents.xml"; curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST'); curl_setopt($ch, CURLOPT_POSTFIELDS, $post_params); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $xml_string = curl_exec($ch); if (!$xml_string) { throw new Vuzit_Exception('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_Exception("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_Exception("Error loading XML response"); } if ($xml->code) { throw new Vuzit_Exception($xml->msg, (int) $xml->code); } if (!$xml->web_id) { throw new Vuzit_Exception("Unknown error occurred"); } // Success! $result = new Vuzit_Document(); $result->setId($xml->web_id); return $result; }