Whois de dominios php api en json?

Asked

Viewed 596 times

0

  • I tried to use other generic sites that do whois but both using Curl and file_get_contents is blocked..

1 answer

1

I discovered this site: http://jsonwhoisapi.com/

Does what you need and is quite easy to use. Below PHP code ready for you to test:

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://jsonwhoisapi.com/api/v1/whois?identifier=google.com');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, $api_token); // trocar por sua ID:key
$response = curl_exec($ch);
if( curl_getinfo($ch, CURLINFO_HTTP_CODE) !== 200 )
{
    // em caso de erro na request
    die("Erro ao puxar jsonwhoisapi - HTTP_CODE: (". curl_getinfo($ch, CURLINFO_HTTP_CODE) .")". print_r($response, true), 0);
}
curl_close($ch);

$dados = json_decode($response);

print_r($dados);

Browser other questions tagged

You are not signed in. Login or sign up in order to post.