Welcome to show the recipient's website PR

Source: Internet
Author: User
It's okay to think about a slightly cheap function. It shows the other party's pr on the welcome visitor interface. This can also be widely used in comments and User links, but it's too cheap, so I decided to show the visitor only. you can see the results. By the way, the url structure of the Googlepagerank API is as follows: toolbarqueries. google. c

It's okay to think about a slightly cheap function. It shows the other party's pr on the welcome visitor interface. This can also be widely used in comments and User links, but it's too cheap, so I decided to show the visitor only. the results should have been seen, by the way, with a picture of Google pagerank API address structure is as follows: http://toolbarqueries.google.c

It's okay to think about a slightly cheap function. It shows the other party's pr on the welcome visitor interface. This can also be widely used in comments and User links, but it's too cheap, so I decided to show the visitor only.
You should have seen the results. By the way, please refer to a picture.

The API address structure of Google pagerank is as follows:

http://toolbarqueries.google.com.hk/tbr?client=navclient-auto&features=Rank&q=info:xiaohudie.net&ch=820909c8a

The value of the ch below is equivalent to a key, which requires php computation. However, during a local test, I found that the computation result is different from that on my website, at present, I do not know whether it is a PHP version or a Windows or LINUX issue. So let's give both calculation methods. If the first method does not call up the correct PR, replace it with the second one.
To query the PHP version, follow these steps:

The following code shows the visitor's website PR

Code 1

This is what I tested on my website. The operating system is LINUX and PHP version is 5.2.17.

 > 23) & 0x1FF) | $ hash <9;} return sprintf ("8% x", $ hash) ;}$ domain1 = $ _ COOKIE ["comment_author_url _". COOKIEHASH]; $ domain = substr ($ domain1, 7); // remove the http: // in front of the visitor's URL and keep only domain $ startUrl = "http://toolbarqueries.google.com/tbr? Client = navclient-auto & features = Rank & q = info: "; $ hash = substr (app_hash_url ($ domain), 9 ); // because the ch value obtained during hash calculation on my website is incorrect, we can see that we need to cut $ resultUrl = $ startUrl from the first 10th bits. $ domain. "& ch = 8 ". $ hash; $ array = get_headers ($ resultUrl, 1); if (! Preg_match ('/403/', $ array [0]) {// This previous article mentioned to determine whether the page can be read accurately, when no pr is available, the api will jump to 403 $ pageContent = file_get_contents ($ resultUrl); $ pageRank = substr ($ pageContent, 9); echo $ pageRank ;} else {echo "0" ;}}?>
Code 2

This is the code that passes the local test, operating system WIN7, PHP version 5.2.14

 > 23) & 0x1FF) | $ hash <9;} return sprintf ("8% x", $ hash ); // It seems that the WIN host can calculate the exact ch value directly} $ domain1 = $ _ COOKIE ['comment _ author_url _'. COOKIEHASH]; $ domain = substr ($ domain1, 7); $ startUrl = "http://toolbarqueries.google.com/tbr? Client = navclient-auto & features = Rank & q = info: "; $ resultUrl = $ startUrl. $ domain. '& ch = '. app_hash_url ($ domain); $ array = get_headers ($ resultUrl, 1); if (! Preg_match ('/403/', $ array [0]) {$ pageContent = file_get_contents ("$ resultUrl"); $ pageRank = substr ($ pageContent, 9 ); echo $ pageRank;} else {echo '0' ;}}?>

If you want to use it elsewhere to query the PR of some websites, modify it.$domainThe value is enough. I'm tired of writing. You can't give me more than 30 comments as you did in the last two articles.

Original article address: A visitor is welcome to display the recipient's website PR. Thank you for sharing it with the original author.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.