-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f9f9550
commit 071e10a
Showing
26 changed files
with
666 additions
and
528 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import java.io.IOException; | ||
import java.io.StringReader; | ||
import java.io.UnsupportedEncodingException; | ||
import java.net.URLEncoder; | ||
|
||
import javax.xml.parsers.DocumentBuilder; | ||
import javax.xml.parsers.DocumentBuilderFactory; | ||
import javax.xml.parsers.ParserConfigurationException; | ||
|
||
import org.apache.http.client.methods.HttpGet; | ||
import org.apache.http.client.ResponseHandler; | ||
import org.apache.http.impl.client.BasicResponseHandler; | ||
import org.apache.http.impl.client.CloseableHttpClient; | ||
import org.apache.http.impl.client.HttpClients; | ||
|
||
import org.w3c.dom.Document; | ||
|
||
import org.xml.sax.InputSource; | ||
import org.xml.sax.SAXException; | ||
|
||
public class WhoisApiV2Sample | ||
{ | ||
public static final String API_URL = | ||
"https://www.whoisxmlapi.com/whoisserver/WhoisService"; | ||
|
||
public static void main(String[]args) throws IOException | ||
{ | ||
String apiKey = "Your Whois API key"; | ||
String domainName = "test.com"; | ||
|
||
String url = API_URL | ||
+ "?domainName=" + URLEncoder.encode(domainName, "UTF-8") | ||
+ "&apiKey=" + URLEncoder.encode(apiKey, "UTF-8"); | ||
|
||
CloseableHttpClient httpclient = null; | ||
|
||
try { | ||
httpclient = HttpClients.createDefault(); | ||
HttpGet httpget = new HttpGet(url); | ||
|
||
System.out.println("executing request " + httpget.getURI()); | ||
|
||
// Create a response handler | ||
ResponseHandler<String> responseHandler = | ||
new BasicResponseHandler(); | ||
|
||
String responseBody = httpclient.execute(httpget,responseHandler); | ||
|
||
System.out.println(responseBody); | ||
System.out.println("----------------------------------------"); | ||
|
||
// Parse | ||
|
||
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); | ||
DocumentBuilder db = dbf.newDocumentBuilder(); | ||
|
||
InputSource is = new InputSource(); | ||
is.setCharacterStream(new StringReader(responseBody)); | ||
|
||
Document doc = db.parse(is); | ||
|
||
System.out.println("Root element " | ||
+ doc.getDocumentElement().getNodeName()); | ||
|
||
} | ||
catch (UnsupportedEncodingException ex) { | ||
ex.printStackTrace(); | ||
} | ||
catch (SAXException ex) { | ||
ex.printStackTrace(); | ||
} | ||
catch (ParserConfigurationException ex) { | ||
ex.printStackTrace(); | ||
} | ||
catch (IOException ex) { | ||
ex.printStackTrace(); | ||
} | ||
finally { | ||
if (httpclient != null) | ||
httpclient.close(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Whois API jQuery JSONP Sample</title> | ||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script> | ||
<script type="text/javascript"> | ||
|
||
var apiUrl = "https://www.whoisxmlapi.com/whoisserver/WhoisService"; | ||
|
||
var apiKey = "Your whois API key"; | ||
var domain = "google.com"; | ||
|
||
$(function() { | ||
$.ajax( | ||
{ | ||
url: apiUrl, | ||
dataType: "jsonp", | ||
data: { | ||
apiKey: apiKey, | ||
domainName: domain, | ||
outputFormat: "json" | ||
}, | ||
success: function(response) { | ||
$("#json").append("<div>JSON answer:</div>" | ||
+ JSON.stringify(response, null,2)); | ||
}, | ||
error: function(e) { | ||
console.log(e); | ||
} | ||
} | ||
); | ||
}); | ||
|
||
</script> | ||
</head> | ||
|
||
<body> | ||
<pre id="json"></pre> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Sample Javascript Whois API Client</title> | ||
<script type="text/javascript"> | ||
|
||
var apiUrl = "https://www.whoisxmlapi.com/whoisserver/WhoisService"; | ||
|
||
// Fill in your details | ||
var apiKey = "Your Whois API key"; | ||
var domain = "google.com"; | ||
var format = "JSON"; | ||
var jsonCallback = "LoadJSON"; | ||
|
||
window.addEventListener("load", onPageLoad, false); | ||
|
||
function onPageLoad() { | ||
// Use a JSON resource | ||
var url = apiUrl | ||
+ "?domainName=" + encodeURIComponent(domain) | ||
+ "&apiKey=" + encodeURIComponent(apiKey) | ||
+ "&outputFormat=" + encodeURIComponent(format); | ||
|
||
// Dynamically Add a script tag to get our JSON data from a | ||
// different server, avoiding cross origin problems. | ||
|
||
var head = document.getElementsByTagName("head")[0]; | ||
var script = document.createElement("script"); | ||
|
||
// The function specified in jsonCallback will be called with a | ||
// single argument representing the JSON object. | ||
|
||
script.type = "text/javascript"; | ||
script.src = url + "&callback=" + jsonCallback; | ||
|
||
head.appendChild(script); | ||
} | ||
|
||
// Do something with the json result | ||
function LoadJSON(result) { | ||
// Print out a nice informative string | ||
document.body.innerHTML += "<div>JSON:</div>" | ||
+ RecursivePrettyPrint(result); | ||
} | ||
|
||
function RecursivePrettyPrint(obj) { | ||
var str = ""; | ||
|
||
for (var x in obj) { | ||
if (obj.hasOwnProperty(x)) { | ||
str += '<div style="' | ||
+ "margin-left: 25px;border-left:1px solid black" | ||
+ '">' + x + ": "; | ||
if (typeof(obj[x]) == "string") | ||
str += obj[x]; | ||
else | ||
str += RecursivePrettyPrint(obj[x]); | ||
str += "</div>"; | ||
} | ||
} | ||
|
||
return str; | ||
} | ||
|
||
</script> | ||
|
||
</head> | ||
<body> | ||
</body> | ||
</html> |
Oops, something went wrong.