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 }
protected static function postParameters($method, $params, $id = '') { if ($params == null) { $params = array(); } $params['method'] = $method; $params['key'] = Vuzit_Service::getPublicKey(); // Signature variables $timestamp = time(); $params['timestamp'] = sprintf("%d", $timestamp); $pages = ''; if (array_key_exists("included_pages", $params)) { $pages = $params["included_pages"]; } $label = ''; // Create the signature $sig = Vuzit_Service::signature($method, $id, $timestamp, $pages, $label); $params['signature'] = $sig; return $params; }
<?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; ?>
protected static function postParameters($method, $params, $id = '') { if ($params == null) { $params = array(); } $params['method'] = $method; $params['key'] = Vuzit_Service::getPublicKey(); // Signature variables $timestamp = time(); $params['timestamp'] = sprintf("%d", $timestamp); $sig = Vuzit_Service::signature($method, $id, $timestamp, $params); $params['signature'] = $sig; return $params; }
public static function setUserAgent($agent) { self::$userAgent = $agent + " (" + self::$productName + ")"; }
Vuzit_Service::setPublicKey('does not exist'); $doc = Vuzit_Document::findById($show_id); } catch (Vuzit_ClientException $ex) { $exception = $ex; } break; case "doc_does_not_exist": try { $doc = Vuzit_Document::findById("doesnotexistblah"); } catch (Vuzit_ClientException $ex) { $exception = $ex; } break; case "invalid_signature": try { Vuzit_Service::setPrivateKey('not_a_valid_key'); $doc = Vuzit_Document::findById($show_id); } catch (Vuzit_ClientException $ex) { $exception = $ex; } break; } ?> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml"> <head> <title>Error Tests</title> </head> <body onload=""> <h2> Error tests
Vuzit_Service::$PublicKey = 'does not exist'; $doc = Vuzit_Document::findById($show_id); } catch (Vuzit_Exception $ex) { $exception = $ex; } break; case "doc_does_not_exist": try { $doc = Vuzit_Document::findById("doesnotexistblah"); } catch (Vuzit_Exception $ex) { $exception = $ex; } break; case "invalid_signature": try { Vuzit_Service::$PrivateKey = 'not_a_valid_key'; $doc = Vuzit_Document::findById($show_id); } catch (Vuzit_Exception $ex) { $exception = $ex; } break; } ?> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml"> <head> <title>Error Tests</title> </head> <body onload=""> <h2> Error tests
<?php require_once '../lib/vuzit.php'; Vuzit_Service::$PublicKey = 'b12c30a5-77aa-ef5f-9b4f-b83a4f88149e'; Vuzit_Service::$PrivateKey = 'YOUR_PRIVATE_KEY'; //Vuzit_Service::$ServiceUrl = 'http://vuzit.net'; $show_id = "4";
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; }
private static function postParams($method, $params) { $params['method'] = $method; $params['key'] = Vuzit_Service::$PublicKey; $timestamp = time(); $sig = Vuzit_Service::getSignature($method, $params['id'], $timestamp); $params['signature'] = $sig; $params['timestamp'] = sprintf("%d", $timestamp); $result = array(); foreach ($params as $key => &$val) { if (!empty($val)) { if (is_array($val)) { $val = implode(',', $val); } if ($key != 'upload' && substr($val, 0, 1) == "@") { $val = chr(32) . $val; } $result[$key] = $val; } } return $result; }