Skip to content

Instantly share code, notes, and snippets.

@weppos
Created April 2, 2012 08:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save weppos/2281820 to your computer and use it in GitHub Desktop.
Save weppos/2281820 to your computer and use it in GitHub Desktop.
RoboWhois + PHP example: get the parsed WHOIS record for a domain.
<?php
/* Requests the parsed WHOIS record for the domain
* and returns an Array containing the parsed WHOIS properties.
*
* @param string $domain The domain to lookup.
*
* @return array
*/
function whoisProperties($domain)
{
$username = 'YOUR_API_KEY';
$password = 'X';
$template = 'http://api.robowhois.com/whois/DOMAIN/properties';
// Initializing curl
$ch = curl_init();
// Configuring curl options
curl_setopt($ch, CURLOPT_URL, str_replace('DOMAIN', $domain, $template));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERPWD, $username . ':' . $password);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: application/json'));
curl_setopt($ch, CURLOPT_USERAGENT, 'PHP/' . phpversion());
// Getting JSON result as string
$response = curl_exec($ch);
// Decode the JSON response into an Array
return json_decode($response);
}
print_r(whoisProperties('google.com'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment