PHP code example of shapito27 / whois-parser

1. Go to this page and download the library: Download shapito27/whois-parser library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

shapito27 / whois-parser example snippets


Shapito27\Whois\Whois::__set_state(array(
   'status' => 1,
   'creationDate' => '1997-03-29 05:00:00',
   'updateDate' => '2020-03-10 18:53:59',
   'expirationDate' => '2028-03-30 04:00:00',
   'nameServers' => 
  array (
    0 => 'a.ns.facebook.com',
    1 => 'b.ns.facebook.com',
    2 => 'c.ns.facebook.com',
    3 => 'd.ns.facebook.com',
  ),
   'registrar' => 
  Shapito27\Whois\Registrar::__set_state(array(
     'id' => '3237',
     'name' => 'RegistrarSafe, LLC',
     'abuseContactEmail' => '[email protected]',
     'abuseContactPhone' => '+1.6503087004',
  )),
   'registryDomainId' => '2320948_DOMAIN_COM-VRSN',
   'errorMessage' => NULL,
))

$domains = [
'facebook.com' => 'facebook whois text',
 'google.com' => 'google whois text'
];

//set domain name and output of its whois data
$parser = new \Shapito27\Whois\WhoisParser();

foreach($domains as $domain => $whoisText) {
    $parser->setDomainName($domain);
    //set formatter each iteration
    $parser->detectFormat();
    $parser->setWhoisText($whoisText);
    
    //run parsing whois data
    $whoisParserResult = $parser->run();
    
    //check if any error
    if (!empty($whoisParserResult->getErrorMessage())) {
         die($whoisParserResult->getErrorMessage());
     }
    
    //get and output whois object 
    var_dump($whoisParserResult->getWhois());
    //display errors
    var_dump($whoisParserResult->getErrorMessage());
}