在CodeIgniter中获取whois输出

时间:2016-07-18 10:52:00

标签: codeigniter whois

我想从我的CodeIgniter控制器调用WHOIS域查找服务,并需要返回数组输出。我刚刚与WHOIS支持团队讨论过,他们说他们没有提供API调用。你知道怎么做吗?

1 个答案:

答案 0 :(得分:0)

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);
        }
    }
  }

?>