Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save tareq1988/f3840b67b2668b0b920f87fe0d4e53aa to your computer and use it in GitHub Desktop.
Save tareq1988/f3840b67b2668b0b920f87fe0d4e53aa to your computer and use it in GitHub Desktop.
<?php
$sites = "http://www.broadcastsolutions.com.au/
http://www.kvm.com.au/
http://www.ambertech.com.au/";
$sites = preg_split('/\r\n|\r|\n/', $sites);
echo "
<style>
img {float: left; margin: 15px; }
</style>
";
foreach($sites as $site)
{
//cache it
if ( !$image = apc_fetch( "thumbnail:".$site ) )
{
$image = file_get_contents("https://www.googleapis.com/pagespeedonline/v1/runPagespeed?url=$site&screenshot=true");
$image = json_decode($image, true);
//echo "<pre>"; print_r($image); die;
$image = $image['screenshot']['data'];
apc_add("thumbnail:".$site, $image, 2400);
}
$image = str_replace(array('_','-'),array('/','+'),$image);
echo "<img src=\"data:image/jpeg;base64,".$image."\" border='1' />";
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment