内容纲要

[code language=”php”]
<?php
$websiteURL = "http://www.expertphp.in/";
$api_response = file_get_contents("https://www.googleapis.com/pagespeedonline/v2/runPagespeed?url=$websiteURL&screenshot=true");
//decode json data
$result = json_decode($api_response, true);
//screenshot data
$screenshot = $result[‘screenshot’][‘data’];
$screenshot = str_replace(array(‘_’,’-‘),array(‘/’,’+’),$screenshot);
//display screenshot image
echo "<img src=\"data:image/jpeg;base64,".$screenshot."\" />";
?>
[/code]

发表评论

电子邮件地址不会被公开。 必填项已用*标注