Wednesday, December 30, 2009

Search for existing domain names using domainr API

Hello friends,

Domainr API is used to get the information of existing domain names. it is working for all domains ( most probably might not be work for subdomains).


See the following php script :


<? PHP

function getInfo($domain) {

$domain = urlencode($domain); // encode url here…

$request = “http://domai.nr/api/json/search?”;

$request .= “q=”.$domain.”&”;

return $response = file_get_contents($request);


}

? >

Pass the domain name to that function like : ( without http )


<? PHP

$data=getInfo(‘www.anil2u.info’);


? >

Get the results in the json format and convert into string:

<? PHP

$obj = json_decode($data);

echo “This domain is “.$obj->{‘results’}[0]->{‘availability’} ;


? >

Demo @ http://www.anil2u.info/domainchecking.php

No comments:

Post a Comment