Due to recent changes made by Google in its Page Rank processing the following library doesn’t work. However you can try to use the following api made available by fusionswift.com:
http://www.fusionswift.com/2011/10/google-pagerank-api-in-php-october-2011/
Mark Woodman has created a nifty class which lets you query Google pagerank info in PHP 5 and above. The complete classes are available here.
The minimum classes required are ‘cacher.class.php‘ and ‘google_pagerank.class.php‘.
Sample code is shown below.
require_once("popstats/google_pagerank.class.php");
$rankObject = new GooglePageRank("http://www.someDomain.com");
$pageRank = $rankObject->pagerank;
echo $pageRank;
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):
$rankObject = new GooglePageRank("http://www.someDomain.com", 21600);
The default is set to 24 hours, which is more then adequate for most purposes.
is there a code for php 4
what exact version of PHP 4 are you asking.
Does the script? I’ve had a few that did not work.
It works. For e.g it gives a page rank of ‘4’ for ‘smashingmagazine.com’.
Thanks for this little piece of code, it’s nice base for my script 🙂
This topic is a little old, but files are still there so I’d like to suggest something:
In line 50 of google_pagerank.class.php file you used ‘urlencode’ function. It works until there is ‘&’ in link string, otherwise ‘&’ is treated as another Google’s parameter. Changing ‘urlencode’ to ‘rawurlencode’ solves the problem.
Nice work btw!
P.S. Another little suggestion: try adding cURL (if unable to file_get_contents) and various Google Server (and get it random when checking – that way you won’t have to do ‘usleep’ being afraid of ban from Google).
hey,
Have you solved it already? i want to use it on my website:
http://www.ozrot.co.il
Good morning,
we are announcing you Eman Engine Stats, a useful FREE script to show important informations of a web site ranking, backlinks and indexing.
It is free. We attach you a presentation below.
A demo version is downloadable from this link and is also attached :
http://www.siti-web-bologna.it/eman_engine_stats_demo.zip
The web site of the script is http://www.siti-web-bologna.it
The full version is downloadable only from our web site with the request of a recip link.
You can show it on your web page
For contact : http://www.siti-web-bologna.it
Thanks and good work to everybody,
Emanuel Celano
Eman Engine Stats is an important php and flash script to check your ranking, backlinks and indexed pages directly from your web site (NO DEPENDENCIES from other web sites), every time you desire or automatically with an include file that run like a cronjob.
Do you want to check your Google Ranking, Alexa Ranking ? Do you want to know the number of backlinks and the number of indexed pages from Google, Yahoo, Msn, Altavista, Alltheweb and to monitor the total value at a glance ? Do you want to look at the differences between two checking, to monitor on real time your search engine visibility ? Useful for web companion of submission and optimization on search engines. Do you want a tool that fit to your graphical page ? You can do it with the possibility to change the flash file background colour by your own.
Eman Engine Stats is for you ! And it is free ! There are two versions of the script. The lite version that is free and the full version, free for now.
To use these tools we only request to provide a link back to our site : http://www.siti-web-bologna.it
The script show also the Google last visit date on your web site and is protected with a login form included into the flash file. It is easy to use thanks to detailed informations of installation step by step.
Nice script could be used for archiving page rank for your sites on a cron job. say, running it once a day. Then, you can see when google is doing another page rank run.
Which is handy information for you and if you have any customers, for them also!
Why would this script always return 0 ?
tnk you
Looking at this 2 years later, I’ve realized that Google has changed their pagerank hashing. I have created an API which can be used to retrieve the pagerank of a page. If you’re interested, you can find it at http://fusionswift.com/201004/google-pagerank-script-in-php/
Wonderful. I will use it too.
Thanks for the scripts.
This code for page rank is not working.
It works on PHP 5 too. Great job! 🙂
Thanks for free api. I’m going to use.
Great work thank you
Awesome little script, just needs alittle update and it will work. Good share.
Great information. Lucky me I ran across your
website by chance (stumbleupon). I have saved as a favorite for
later!
Thanks for youre Class PHP, Usefull !!!
thanks, still works in 2014! 🙂
is this still working?
Yeah thanks… tested on https://www.teamlgm.com
Awesome PHP Scripts!! 🙂 Its Working..
http://www.fazseo.com
it’s still working !!!
http://pagerankcamp.com