Created
March 10, 2014 08:49
-
-
Save weppos/9461565 to your computer and use it in GitHub Desktop.
RoboWhois + C# example: get the WHOIS record for a domain.
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
public string WhoIs(string domainName, string myApiKey) | |
{ | |
string url = "http://api.robowhois.com/whois/" + domainName; | |
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); | |
request.Method = WebRequestMethods.Http.Get; | |
request.Credentials = new NetworkCredential(myApiKey, "X"); | |
try | |
{ | |
WebResponse response = request.GetResponse(); | |
if (((HttpWebResponse)response).StatusCode == HttpStatusCode.OK) | |
{ | |
Stream receiveStream = response.GetResponseStream(); | |
StreamReader readStream = new StreamReader(receiveStream, Encoding.UTF8); | |
return readStream.ReadToEnd(); | |
} | |
return "Could not connect to server or Api is wrong"; | |
} | |
catch(System.Exception exc) | |
{ | |
return "Could not connect to server or Api is wrong"; | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment