Search code examples
codeigniterwhois

Get whois output in CodeIgniter


I want to call WHOIS domain lookup services from my CodeIgniter controller and need return array output. I just discussed with WHOIS support team, they said they do not provide API call. Do you have any idea how to do this?


Solution

  • I Got Best way to call WHOIS domain lockup services
    
    <?php
      $username="username";
      $password="password"; 
      $contents = file_get_contents("http://www.whoisxmlapi.com//whoisserver/WhoisService?domainName=google.com&username=$username&password=$password&outputFormat=JSON");
      //echo $contents;
      $res=json_decode($contents);
      if($res){
        if($res->ErrorMessage){
            echo $res->ErrorMessage->msg;
        }   
        else{
            $whoisRecord = $res->WhoisRecord;
            if($whoisRecord){
                echo "Domain name: " . print_r($whoisRecord->domainName,1) ."<br/>";
                echo "Created date: " .print_r($whoisRecord->createdDate,1) ."<br/>";
                echo "Updated date: " .print_r($whoisRecord->updatedDate,1) ."<br/>";
                if($whoisRecord->registrant)echo "Registrant: <br/><pre>" . print_r($whoisRecord->registrant->rawText, 1) ."</pre>";
                //print_r($whoisRecord);
            }
        }
      }
    
    ?>