How to get Google PageRank using php
Posted: Sat Mar 13, 2010 4:56 pm
Step 1: Download following zip file that contain required files from popstats
Step 2: Now you can use call Google PageRank as below.
The class also supports result caching on the local machine, so if a second query arrives within the cache time limit the result saved in the local file is returned rather then going out and querying Google.
The ‘GooglePageRank’ class accepts cache time as a second parameter. So if you want to cache the result for 6 hours you set the second parameter for 21600 seconds (6 * 60 * 60):
The default is set to 24 hours, which is more then adequate for most purposes.
Code: Select all
require_once("google_pagerank.class.php");
$rankObject = new GooglePageRank("http://www.yourdomain.com/");
$pageRank = $rankObject->pagerank;
echo $pageRank;
The ‘GooglePageRank’ class accepts cache time as a second parameter. So if you want to cache the result for 6 hours you set the second parameter for 21600 seconds (6 * 60 * 60):
Code: Select all
$rankObject = new GooglePageRank("http://www.yourdomain.com/", 21600);