Wednesday, October 6, 2010

How Long Does It Take A Malignant Mole To Spread

Google Pagerank in PHP Script

Lately, I am very confused to find how to get the PageRank of a website. At first, I thought that Google provides a web service so I can use. Apparently not.

Finally I find out on the internet, and found a script that can help me. Here is a function to get the pagerank that are made in the form of function:
function PageRank ($ url) {
if (function_exists ('curl_init')) {$ ch = curl_init
();
curl_setopt ($ ch, CURLOPT_URL, 'http://api.fusionswift.com/pagerank/?url =' . $ Url);
curl_setopt ($ ch, CURLOPT_HEADER, 0);
curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, 1);
$ googleurl = curl_exec ($ ch);
curl_setopt ($ ch, CURLOPT_URL, $ googleurl);
$ out = curl_exec ($ ch);
curl_close ($ ch);} else {

$ googleurl = file_get_contents ('http://api.fusionswift.com/pagerank/?url ='. $ url);
$ out = file_get_contents ($ googleurl);
}
$ pieces = explode (':', $ out);
$ pr = $ pieces [2];
return trim ($ pr);
}
To call the function can be used The following script:
$ Url = "http://hikarianna.blogspot.com/";
echo "PageRank from". $ Url. "Is =". PageRank ($ url);
following script can be downloaded HERE .

Source:
http://fusionswift.com/blog/2010/04/google-pagerank-script-in-php/

0 comments:

Post a Comment