Reply to topic
Add "Domain Availability Search" functionality.
sabersrock18


Joined: 20 May 2007
Posts: 5
Reply with quote
I am basically trying to figure out if it is possible to add the ability for my clients to Lookup Domain Availability from my website. I want them to purchase it through me and then I will purchase it through hostmysite. That way I can mark it up a little.

Any ideas.
Jason101
Forum Regular

Joined: 14 Mar 2006
Posts: 570
Location: Harrisburg, PA
Reply with quote
You most certainly can. It's fairy easy. But first, what language do you want to use?
sabersrock18


Joined: 20 May 2007
Posts: 5
Reply with quote
I completally forgot about this post...

if you are still out there, i am most comfortable with php
jamie
HostMySite Sales Rep
HostMySite Sales Rep

Joined: 19 Mar 2004
Posts: 858
Location: Newark, De
Reply with quote
We actually have an API that you can use for this; just contact support and they can give you access to it.
nathacof
Forum Admin

Joined: 24 Oct 2006
Posts: 192
Location: Dover, DE
Reply with quote
I wrote my own WHOIS lookup script:

http://neranjara.org/tools/whois
http://neranjara.org/tools/ipwhois

It's fairly straightforward once you read the relevant documentation.

Simply open up a socket to the whois server and shoot the domain through. Once there the whois server will spit back the info you're looking for.

http://en.wikipedia.org/wiki/WHOIS

whois-servers.net is a great domain whose subdomains point to the corresponding whois server IE:
Code:

$ dig +short org.whois-servers.net
whois.publicinterestregistry.net.
149.17.192.7

$ dig +short net.whois-servers.net
whois.verisign-grs.com.
199.7.51.74


So you simply connect on port 43 to the corresponding domain, write your domain on the socket followed by a carriage return and line feed ("\r\n"), and read the resulting output.

This is how the whois tool on Linux works at least, so I modeled my tool after it, and it works wonders. IPWhois is a similar scenario only there are a limited number of IPWHOIS servers:

Code:
<?php
$servers = array('ARIN'    => 'whois.arin.net',
                 'RIPE'    => 'whois.ripe.net',
                 'APNIC'   => 'whois.apnic.net',
                 'LACNIC'  => 'whois.lacnic.net',
                 'AfriNIC' => 'whois.afrinic.net' );


Last edited by nathacof on Mon Jun 29, 2009 11:56 pm; edited 7 times in total
nathacof
Forum Admin

Joined: 24 Oct 2006
Posts: 192
Location: Dover, DE
Reply with quote
I rewrote this based on my personal code:

Code:
<?php
/*
 *  Function accepts the domain for
 *  which we want the WHOIS information
 *  default value is example.com
 */
function getWhoisText($domain = 'example.com') {
/*
 *  whois-servers.net provides
 *  information pertaining to relevant
 *  whois servers
 */
$WHOIS = 'whois-servers.net';

/*
 * This code breaks a domain into it's
 * atomic parts and reverses their order
 */
$tmp = array_reverse(explode('.', $domain));

/*
 * Here we set the the appropriate WHOIS
 * server based on the Top Level Domain
 */
$server = $tmp[0] . "." . $WHOIS;

/*
 * Connect to the WHOIS server
 */
if(!$link = fsockopen($server, 43, $errno, $errstr, 15)) {
        trigger_error("Error (" . $errno . "): " . $errstr .
                      "Could not connect to " . $server, 
                      E_USER_ERROR);
        return false;
}

/*
 * write the domain to the socket
 */
if(!fwrite($link, $domain. "\r\n")){
        trigger_error("Error: Could not write to socket", 
                      E_USER_ERROR);
        return false;
}

/*
 * collect the returned data
 */
while (!feof($link)){
        $string .= fgets($link, 4096);
}

/*
 * close the socket
 */
fclose($link);

/*
 * return whois information
 */
return $string;
}

Code:

/*
 *  Function accepts the IP for
 *  which we want the WHOIS information
 */
function getIpWhoisText($ip, $server = 'ARIN') {
/*
 * Validate IP Address
 */
if(!ip2long($ip)) {
    trigger_error("Invalid IP Address",
                  E_USER_NOTICE);
    return false;
}
/*
 * List of servers
 */
$SERVERS = array('ARIN'    => 'whois.arin.net',
                 'RIPE'    => 'whois.ripe.net',
                 'APNIC'   => 'whois.apnic.net',
                 'LACNIC'  => 'whois.lacnic.net',
                 'AfriNIC' => 'whois.afrinic.net' );
/*
 * Check that the server exists in our array
 */
if(!array_key_exists($server, $SERVERS)) {
    trigger_error("Invalid Server type, must be one of, " .
                  implode(", ", array_keys($SERVERS)) . ".",
                  E_USER_NOTICE);
    return false;   
}


/*
 * Here we set the the appropriate WHOIS
 * server
 */
$server = $SERVERS[$server];

/*
 * Connect to the WHOIS server
 */
if(!$link = fsockopen($server, 43, $errno, $errstr, 15)) {
        trigger_error("Error (" . $errno . "): " . $errstr .
                      "Could not connect to " . $server, 
                      E_USER_NOTICE);
        return false;
}

/*
 * write the ip to the socket
 */
if(!fwrite($link, $ip. "\r\n")){
        trigger_error("Error: Could not write to socket", 
                      E_USER_NOTICE);
        return false;
}

/*
 * collect the returned data
 */
while (!feof($link)){
        $string .= fgets($link, 4096);
}

/*
 * close the socket
 */
fclose($link);

/*
 * return whois information
 */
return $string;
}
Add "Domain Availability Search" functionality.
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT  
Page 1 of 1  

  
  
 Reply to topic