< >

snapshout-from-webseize.php


Quell Code


<form method="post" action="snapshout-from-webseize.php" >
<p>Website URL: <input type="text" name="url" value="" /></p>
<input type="submit" name="submit" value="CAPTURE">
</form>
 
<?php
if(!empty($_POST['url'])){
    //website url
    $siteURL = $_POST['url'];

    if(filter_var($siteURL, FILTER_VALIDATE_URL)){
        //call Google PageSpeed Insights API
        $googlePagespeedData = file_get_contents("https://www.googleapis.com/pagespeedonline/v2/runPagespeed?url=$siteURL&screenshot=true");

        //decode json data
        $googlePagespeedData = json_decode($googlePagespeedData, true);

        //screenshot data
        $screenshot = $googlePagespeedData['screenshot']['data'];
        $screenshot = str_replace(array('_','-'),array('/','+'),$screenshot);
//http://image.thum.io/get/width/400/crop/800/http://www.google.com/
        //display screenshot image
        echo "<img src=\"data:image/jpeg;base64,".$screenshot."\" />";
    }else{
        echo "Please enter a valid URL.";
    }
}
?>

Add Comment

* Required information
1000
Powered by Commentics

Comments (1)

Gravatar
Admin
Sascha65says...

Die Canvas Balken Uhr ist ja mal Fett