Easy to use rich snippets
<body> ... <star-snippet></star-snippet> ... </body>
<body> ... <!-- star-snippets.com --> <script> (function() { function async_load(){ var s = document.createElement('script'); s.type = 'text/javascript'; s.async = true; s.src = 'http://star-snippets.com/script'; //s.src = 'http://star-snippets.com/script?prevent_cache=' + new Date().getTime(); //prevent caching var x = document.getElementsByTagName('script')[0]; x.parentNode.insertBefore(s, x); } if (window.attachEvent) window.attachEvent('onload', async_load); else window.addEventListener('load', async_load, false); })(); </script> </body> <!-- integrate directly before the closing body tag -->
<body> ... <?php //The url Parameter should match the href Parameter of the javascript code $url = "http://star-snippets.com/rating?url=http://www.example.com"; $title = "Example-Page"; $description = "a description of your example page"; if($title != "") { $url .= "&name=".rawurlencode($title); } if($description != "") { $url .= "&description=".rawurlencode($description); } $timeout = 10; try { $streamContext = stream_context_create(array('http' => array('timeout' => $timeout))); $response = file_get_contents($url, false, $streamContext); if (!$response) {} else { echo $response; } } catch (Exception $ex) { } ?> ... </body>
// Comment this line // $response = file_get_contents($url, false, $streamContext); // use following lines instead $session = curl_init($url); curl_setopt($session, CURLOPT_HEADER, false); curl_setopt($session, CURLOPT_RETURNTRANSFER, true); curl_setopt($session, CURLOPT_TIMEOUT, $timeout); $response = curl_exec($session); curl_close($session);
<body> ... <star-snippet></star-snippet> ... </body>
<body> ... <?php $doc = JFactory::getDocument(); $url = "http://star-snippets.com/rating?url=".JURI::current(); if($doc->getTitle() != "") { $url .= "&name=".rawurlencode($doc->getTitle()); } if($doc->getDescription() != "") { $url .= "&description=".rawurlencode($doc->getDescription()); } $timeout = 10; try { $streamContext = stream_context_create(array('http' => array('timeout' => $timeout))); $response = file_get_contents($url, false, $streamContext); if (!$response) {} else { echo $response; } } catch (Exception $ex) { } ?> <!-- star-snippets.com --> <script> (function() { function async_load(){ var s = document.createElement('script'); s.type = 'text/javascript'; s.async = true; s.src = 'http://star-snippets.com/script'; //s.src = 'http://star-snippets.com/script?prevent_cache=' + new Date().getTime(); //prevent caching var x = document.getElementsByTagName('script')[0]; x.parentNode.insertBefore(s, x); } if (window.attachEvent) window.attachEvent('onload', async_load); else window.addEventListener('load', async_load, false); })(); </script> </body>
// Comment this line // $response = file_get_contents($url, false, $streamContext); // use following lines instead $session = curl_init($url); curl_setopt($session, CURLOPT_HEADER, false); curl_setopt($session, CURLOPT_RETURNTRANSFER, true); curl_setopt($session, CURLOPT_TIMEOUT, $timeout); $response = curl_exec($session); curl_close($session);