From 9483a179784ed03d7bcd6da4e7dcefb64a9fe3d7 Mon Sep 17 00:00:00 2001 From: whoisxmlapi Date: Fri, 20 Jul 2018 18:10:01 +0300 Subject: [PATCH] PHP sample. --- php/reverse_whois_api_v2.php | 53 ++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 php/reverse_whois_api_v2.php diff --git a/php/reverse_whois_api_v2.php b/php/reverse_whois_api_v2.php new file mode 100644 index 0000000..5bb39fb --- /dev/null +++ b/php/reverse_whois_api_v2.php @@ -0,0 +1,53 @@ + 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))); \ No newline at end of file