How to create a phpwhois Query API

Source: Internet
Author: User
Tags domain name registration
Websites often need to query the website's whois information. here we will introduce a whoisapi interface created using php. the method is also very simple. The following describes in detail. Here we get data from the data interface of HiChina or Xinnet, and process and output data through simple php text.

The code is as follows:


$ Domain = $ _ GET ['Q'];
Preg_match ("|

(. + ?)


| Is ", @ file_get_contents ('http: // www.xinnet.cn/Modules/agent/serv/pages/domain_whois.jsp? DomainNameWhois = '. $ domain.' & noCode = nocode'), $ whois );
Echo $ whois [1];
?>


Here, some may ask, isn't this a simple php script ?! Which is the api interface? let's work on it to make the query method more professional:
The query format is as follows:
Http: // api/whois/baidu.com
Here, baidu.com is the domain name to be queried.
You can modify the nginx configuration to achieve this:

The code is as follows:


Location ~ */Whois/(. +) $ {
Proxy_pass http: // 127.0.0.1: 8080/whois/index. php? Q = baidu.com
# Apache processing that passes the query to the intranet
}


OK. Now a whois api is used. you can call it in your own program or share it with everyone !.
Query the result of baidu.com:
Whois Server Version 2.0
Domain names in the. com and. net domains can now be registered
With your different competing registrars. Go to http://www.internic.net
For detailed information.
Domain Name: BAIDU. COM
Registrar: REGISTER. COM, INC.
Whois Server: whois.register.com
Referral URL: http://www.register.com
Name Server: DNS. BAIDU. COM
Name Server: NS2.BAIDU. COM
Name Server: NS3.BAIDU. COM
Name Server: NS4.BAIDU. COM
Status: clientTransferProhibited
Status: serverDeleteProhibited
Status: serverTransferProhibited
Status: serverUpdateProhibited
Updated Date: 15-mar-2010
Creation Date: 11--19-1999
Expiration Date: 11-oct-2014
>>> Last update of whois database: Fri, 20 Aug 2010 05:42:12 UTC <
NOTICE: The expiration date displayed in this record is the date
Registrar's unsupported sorship of the domain name registration in the registry is
Currently set to expire. This date does not necessarily reflect the expiration
Date of the domain name registrant's agreement with the sort Soring
Registrar. Users may consult the sort soring registrar's Whois database
View the registrar's reported date of expiration for this registration.
Terms of use: You are not authorized to access or query our Whois
Database through the use of electronic processes that are high-volume and
Automatically synchronized T as reasonably necessary to register domain names or
Modify existing registrations; the Data in VeriSign Global Registry
Services '("VeriSign") Whois database is provided by VeriSign
Information purposes only, and to assist persons in obtaining information
About or related to a domain name registration record. VeriSign does not
Guarantee its accuracy. By submitting a Whois query, you agree to abide
By the following terms of use: You agree that you may use this Data only
For lawful purposes and that under no circumstances will you use this Data
To: (1) allow, enable, or otherwise support the transmission of mass
Unsolicited, commercial advertising or solicitations via e-mail, telephone,
Or facsimile; or (2) enable high volume, automatic, electronic processes
That apply to VeriSign (or its computer systems). The compilation,
Repackaging, dissemination or other use of this Data is expressly
Prohibited without the prior written consent of VeriSign. You agree not
Use electronic processes that are automated and high-volume to access or
Query the Whois database against T as reasonably necessary to register
Domain names or modify existing registrations. VeriSign reserves the right
To restrict your access to the Whois database in its sole discretion to ensure
Operational stability. VeriSign may restrict or terminate your access to
Whois database for failure to abide by these terms of use. VeriSign
Reserves the right to modify these terms at any time.
The Registry database contains ONLY. COM,. NET,. EDU domains and
Registrars.
The data in Register.com's WHOIS database is provided to you
Register.com for information purposes only, that is, to assist you in
Obtaining information about or related to a domain name registration
Record. Register.com makes this information available "as is," and
Does not guarantee its accuracy. By submitting a WHOIS query, you
Agree that you will use this data only for lawful purposes and that,
Under no circumstances will you use this data to: (1) allow, enable,
Or otherwise support the transmission of mass unsolicited, commercial
Advertising or solicitations via direct mail, electronic mail, or
Telephone; or (2) enable high volume, automatic, electronic processes
That apply to Register.com (or its systems). The compilation,
Repackaging, dissemination or other use of this data is expressly
Prohibited without the prior written consent of Register.com.
Register.com reserves the right to modify these terms at any time.
By submitting this query, you agree to abide by these terms.
Registrant:
Beijing Baidu Netcom Science and Technology Co. Ltd.
Baidu Netcom
No. 10, Shangdi 10th Street, Haidian District,
Beijing 100085
CN
Phone: + 86.1059926680
Email: domainmaster@baidu.com
Registrar Name .... : Register.com
Registrar Whois... : Whois.register.com
Registrar Homepage: www.register.com
Domain Name: baidu.com
Created on .............. : 2017-10-11
Expires on .............. : 2014-10-11
Administrative Contact:
Beijing Baidu Netcom Science and Technology Co. Ltd.
Baidu Netcom
No. 10, Shangdi 10th Street, Haidian District,
Beijing 100085
CN
Phone: + 86.1059927440
Email: wumengyi@baidu.com
Technical Contact:
Registercom
Domain Registrar
575 8th Avenue
New York, NY 10018
US
Phone: + 1.9027492701
Email: domainregistrar@register.com
DNS Servers:
Ns3.baidu.com
Ns2.baidu.com
Ns4.baidu.com
Dns.baidu.com
Visit AboutUs.org for more information about baidu.com
AboutUs: baidu.com
Register your domain name at http://www.register.com

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.