Skip to content

Commit e4049f7

Browse files
committed
Added jQuery and PowerShell samples, edited readme
1 parent 52b1e43 commit e4049f7

3 files changed

Lines changed: 55 additions & 4 deletions

File tree

README.MD

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
1-
# Hosted WHOIS API Webservice
1+
# Making a query to Whois API web service
22

33
[WhoisXmlApi.com](https://www.whoisxmlapi.com/) has been gathering domain
4-
Whois records for almost all gTLDs and ccTLDs for over a decade.
4+
Whois records for almost all gTLDs and ccTLDs for over a decade.
55
This data is unified, consistent, well parsed, and accurate and provided
6-
through real-time APIs.
6+
through real-time APIs.
77

8-
Here you'll find code samples of making requests to the available APIs.
8+
Here you'll find examples of using
9+
[www.whoisxmlapi.com](https://www.whoisxmlapi.com/) Hosted Whois Web API
10+
implemented in multiple languages.
11+
12+
Please, refer to
13+
[Whois API User Guide](https://www.whoisxmlapi.com/whois-api-guide.php) for
14+
authentication instructions.

apikey/js/whois_jquery_jsonp.html

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
2+
<script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/3.1.9-1/
3+
crypto-js.js"></script>
4+
<script type="text/javascript">
5+
var domain = "example.com";
6+
var key = "your whois api key";
7+
var secret = "your whois api secret key"
8+
var username = "your whois api username";
9+
10+
$(function () {
11+
var time = (new Date()).getTime();
12+
var req = btoa(unescape(
13+
encodeURIComponent(JSON.stringify({t:time,u:username}))));
14+
var digest = CryptoJS.HmacMD5(
15+
username+time+key,secret).toString(CryptoJS.enc.Hex);
16+
$.ajax({
17+
url: "http://www.whoisxmlapi.com/whoisserver/WhoisService",
18+
dataType: "jsonp",
19+
data: {requestObject: req, digest: digest,
20+
domainName: domain, outputFormat: "JSON"},
21+
success: function(data) {
22+
$("body").append("<pre>"+ JSON.stringify(data,"",2)+"</pre>");
23+
}
24+
});
25+
});
26+
</script>

apikey/powershell/whois.ps1

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
$domain = "example.com"
2+
$key = "your whois api key"
3+
$secret = "your whois api secret key"
4+
$username = "your whois api username"
5+
6+
$time = [DateTimeOffset]::Now.ToUnixTimeMilliseconds()
7+
$req=[Text.Encoding]::UTF8.GetBytes("{`"t`":$($time),`"u`":`"$($username)`"}")
8+
$req = [Convert]::ToBase64String($req)
9+
10+
$data = $username + $time + $key
11+
$hmac = New-Object System.Security.Cryptography.HMACMD5
12+
$hmac.key = [Text.Encoding]::UTF8.GetBytes($secret)
13+
$hash = $hmac.ComputeHash([Text.Encoding]::UTF8.GetBytes($data))
14+
$digest = [BitConverter]::ToString($hash).Replace('-','').ToLower()
15+
16+
$uri = "https://www.whoisxmlapi.com/whoisserver/WhoisService?"`
17+
+ "requestObject=$($req)&digest=$($digest)&domainName=$($domain)"
18+
19+
echo (Invoke-WebRequest -Uri $uri).Content

0 commit comments

Comments
 (0)