Skip to content

Commit

Permalink
PHP sample.
Browse files Browse the repository at this point in the history
  • Loading branch information
whoisxmlapi committed Jul 20, 2018
1 parent e6610ac commit 9483a17
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions php/reverse_whois_api_v2.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php

$apiKey = 'Your reverse whois api key';

$termsAdvanced = array(
'advancedSearchTerms' => array(
array(
'field' => 'RegistrantContact.Name',
'term' => 'Test'
)
),
'mode' => 'purchase',
'apiKey' => $apiKey,
'sinceDate' => '2018-07-15'
);

$termsBasic = array(
'basicSearchTerms' => array(
'include' => array(
'test'
),
'exclude' => array(
'whois',
'api'
)
),
'mode' => 'purchase',
'apiKey' => $apiKey,
'sinceDate' => '2018-07-15'
);

function reverse_whois_api(array $data=array())
{
$header ="Content-Type: application/json\r\nAccept: application/json\r\n";

$url = 'https://reverse-whois-api.whoisxmlapi.com/api/v2';

$options = array(
'http' => array(
'method' => 'POST',
'header' => $header,
'content' => json_encode($data)
)
);

return file_get_contents($url, false, stream_context_create($options));
}

print('Basic:' . PHP_EOL);
print_r(json_decode(reverse_whois_api($termsBasic)));

print('Advanced:' . PHP_EOL);
print_r(json_decode(reverse_whois_api($termsAdvanced)));

0 comments on commit 9483a17

Please sign in to comment.