Created
April 8, 2014 10:12
-
-
Save kayalshri/10106810 to your computer and use it in GitHub Desktop.
Google Page Speed online test api
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$search_url = (@$_GET['url']) ? : "http://ngiriraj.com/pincode/"; | |
$api_key = "xxxxxxxxxxxxxxxxxxx"; | |
//https://console.developers.google.com/ | |
$speed_url = "https://www.googleapis.com/pagespeedonline/v1/runPagespeed?url=".$search_url."&key=".$api_key; | |
print "URL : <BR>".$search_url; | |
$ch = curl_init ($speed_url); | |
curl_setopt($ch, CURLINFO_HEADER_OUT, true); | |
curl_setopt($ch, CURLOPT_HEADER, 0); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | |
curl_setopt($ch, CURLOPT_BINARYTRANSFER,1); | |
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); | |
curl_setopt($ch, CURLOPT_VERBOSE, true); | |
$rawdata=curl_exec($ch); | |
curl_close ($ch); | |
$jsonData = json_decode($rawdata,true); | |
?> | |
<div class="col-md-12"> | |
<span class="chart" data-percent="<?php echo $jsonData['score']; ?>"> | |
<span class="percent"></span> | |
</span></div> | |
<?php | |
#print $jsonData['score']; | |
print "<BR><BR>Full Data <BR><BR><pre>"; | |
print_r($jsonData); | |
print "</pre>"; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment