Inline SEO Friendly Reviews

 
<!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" xml:lang="en" lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<link id="rezCss" rel="stylesheet" type="text/css" media="screen" href="http://static.reziew.com/assets/widget.css" />
    
  <title>Inline SEO integration sample</title>
</head>
<body>

<div id="reziew-area">
<?php
//That's your shortname
$shortname = "demo";

//Dynamic parameters for product information, please fill all the fields
$params = array("sku" => "pop", "locale" => "en");

//That's the part where we download the content (local cache)
$cacheDir = dirname(__FILE__)."/cache";
$cacheDuration = 3600;

//We check if the file is already cached and if it's still valid
if(file_exists($cacheDir. "/" . $params["sku"] . ".html") && (time() - filemtime($cacheDir. "/" . $params["sku"] . ".html") < $cacheDuration)){
	//Use local cache
	include_once($cacheDir. "/" . $params["sku"] . ".html");
} else {
	
	$ch = curl_init();
	curl_setopt($ch, CURLOPT_URL, "http://" . $shortname . ".reziew.com/api/1/review/renderList.json");
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
	curl_setopt($ch, CURLOPT_HEADER, 0);
        //This is important to leave at least a 5 seconds timeout
	curl_setopt($ch, CURLOPT_TIMEOUT, 5); 
	
	//Post all the params to the api
	curl_setopt($ch, CURLOPT_POST, 1);
        //Add all parameters to the url (renderList.json?param=val1¶m2=val2)
	curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
	$data = curl_exec($ch); 
	$dataObj = (json_decode($data));

	//Write the response to a local cache
	$fp = fopen($cacheDir ."/$sku.html", "w");
	fwrite($fp, $dataObj->html);
	fclose($fp);
//Inject the response into the the div for improved SEO
  echo $dataObj->html;
}

  
?>
</div>
<!-- This is the javascript tag, use all parameters from $params-->
<script type="text/javascript">
  var reziew_options = {
      <?php foreach($params as $key => $val){
	  	echo $key . ": '" . $val . "'," . "\n"; 
	  } ?>
      shortname: '<?php echo $shortname; ?>'
  };

/**** Don't edit below this line, this is a js tag writing the tag ****/
(function() {
var rez = document.createElement('script');rez.type = 'text/javascript';rez.async = true;
var param = ((top.location.hash).match(/(rez_\w+=\w+)/g) || []).join('&').replace(/^rez/, "&rez");
rez.src = 'http://'+reziew_options.shortname+'.reziew.com/widget?format=js&lang='+reziew_options.locale+param;
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(rez);
})();
</script>

</body>
</html>