Skip to content
Advertisement

domain registry api integrate in php

I want to integrate one API with one of my website which is a task given by my senior.The API is about searching domain name already present or not..please help me on this topic please give me n example which i can refer.my website is in PHP.

Advertisement

Answer

[EDIT 2] As @Poe mentions in his comment, gethostbyname is probably a much better solution because it works for any top level domain, since it performs a DNS query instead of a whois query, and is also much simpler to implement and probably faster:

JavaScript

Anyway, a domain can be registered but its not linked to any computer (E.g. although it’s very uncommon, you may get an resolution for www.example.com but not example.com)

[EDIT] I didn’t post this before because I was having some trouble connecting to whois.internic.net on port 43 to perform a whois query (thought they had shutdown the service for good). Anyway, here’s a fsockopen based solution I just coded, which I think is far better and simpler than the solution I gave before using their CGI web script. Hope it helps (Usage: myqueryscript.php?domain=domainiwanttocheck.com):

JavaScript

From internic website, this is the html code to implement a whois query:

JavaScript

This means you can send a whois query like this: http://reports.internic.net/cgi/whois?whois_nic=domainiwanttocheck.com&type=domain

You can send the query from your script and store the response on a DOMDocument object. Check out: http://www.php.net/manual/en/domdocument.loadhtml.php

If you use this method to lookup a domain and the domain doesn’t exist, you’ll get the string No match for domain. Look for this in the response using strpos

If the domain exists, you can filter the response to include the info about registrar, etc. It will be the content of the html tag <pre> of the response:

JavaScript

Also, check out this related question: Who provides a WHOIS API?

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement