"Original" and talk about using PHP to realize domain name whois information query

Source: Internet
Author: User
Previously, in order to do "plog.cn 1-6-bit ultra-looking for the deletion of short domain name screening tool," specifically on the plog.cn server deployed a whois query gadget. PS: How to use http://plog.cn/whois/yourdomain.com

In order to achieve this Whois gadget, looked for a full two hours of information, online there are many kinds of whois query PHP implementation, the idea of the general realization of the following several exceptions:

1. Call xinnet or the WHOIS query interface query via HTTP, then output the results to the page, blog http://blog.163.com/mengqing_dao/blog/static/ 133520513201162634227882/The method described is the simplest, through the indirect invocation of the new network Whois query interface implementation method

2. Directly by reading the WHOIS server, the implementation of the domain name query. The article http://dev.meettea.com/show-78-1.html elaborated method, is according to the queried domain name suffix name, accesses the different WHOIS server, the query result

The mappings between the corresponding domain name suffix and whois server are as follows:

' com ' = ' whois.internic.net ', ' net ' = ' whois.internic.net ', ' org ' = ' whois.pir.org ', ' asia ' = ' Whois.crsnic.net ', ' cn ' = ' whois.cnnic.net.cn ', ' cc ' = ' whois.nic.cc ',

For this method, although the implementation is very simple, but for the GoDaddy.com platform or the domestic Xiamen easy name network registered domain name, can only find a approximate, and can not find the specific real domain information, as follows:

WHOIS information for domain names registered in Godday

WHOIS information for registered domain names in Xiamen yi-Name Network

Therefore, no matter the above two methods, can not be more perfect to implement the WHOIS query function.

At this point Jay felt that it was just a matter of whois and needed a sledgehammer, and we needed a perfect Whois query component.

At this point Jay immediately open google.com, search php whois, sure enough!

in Baidu, searched for a half-day, out are some outside the door odd side, Google a search, immediately appeared a complete set of whois client PHP implementation, project name is called "Phpwhois", Project home: http://www.phpwhois.org/, so immediately Download down, according to the demo in the document, quickly realized the WHOIS query function.

The following is the core code part of invoking the Phpwhois component to implement a WHOIS information query:

  
   Lookup ($domain); $output = implode ("\ n", $result [' rawdata ']); Echo $output; >

Over here

The purpose of the tag is to define the pre-formatted text, which is the raw text that the WHOIS is queried to output directly in the original format.

Domainname:lxfq.cnroid:20130114s10001s62921725-cndomainstatus:okregistrant id:000046dbregistrant: LAF registrantcontactemail:2673732891@qq.comsponsoringregistrar: Beijing Network Zun Technology Co., Ltd. NameServer:ns1.vtopchina.cnNameServer: ns2.vtopchina.cnregistrationdate:2013-01-1404:02:16expirationdate:2014-01-1404:02:16dnssec:unsigned

Summarize:

Whois is just one of the simplest TCP-based query protocols, but a lot of work, even if we are very simple to implement, if there are ready-made PHP components can be used, we should try to avoid the repetition of the invention of a wheel. Not to say no, just to re-implement a protocol, even the simplest kind, you will encounter a lot of exceptions.

Just like the Phpwhois component, it is very good to contend with exceptions like this to GoDaddy.

So, professional things, or let professional open source components to achieve it!

  • 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.