Capture a web image

0

I would like to create an image on my server, the image should contain the web for example if I put $ url="google.es"; must show an image with the google web

I have tried to do with third-party tools but I have not, someone could help me to capture the image and store it on the server ?? Greetings and thanks

    
asked by pablo 08.05.2018 в 13:48
source

1 answer

0

let's see, I already managed to show the image through a google API, but I need to copy it on the server, someone could help me out, I'll put the code

function getGooglePageSpeedScreenshot ($ site, $ img_tag_attributes="border = '1'") {     #initialize     $ use_cache = false;     $ apc_is_loaded = extension_loaded ('apc');

#set $use_cache
if($apc_is_loaded) {
    apc_fetch("thumbnail:".$site, $use_cache);
}

if(!$use_cache) {
    $image = file_get_contents("https://www.googleapis.com/pagespeedonline/v1/runPagespeed?url=http://$site&screenshot=true");
    $image = json_decode($image, true);
    $image = $image['screenshot']['data'];
    if($apc_is_loaded) {
        apc_add("thumbnail:".$site, $image, 2400);
    }
}

$image = str_replace(array('_', '-'), array('/', '+'), $image);
return "<img src=\"data:image/jpeg;base64,".$image."\" 

}

echo getGooglePageSpeedScreenshot($dominio, 'class="thumbnail"');
    
answered by 27.05.2018 / 18:09
source