Skip to content

Instantly share code, notes, and snippets.

@weppos
Created March 10, 2014 08:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save weppos/9461565 to your computer and use it in GitHub Desktop.
Save weppos/9461565 to your computer and use it in GitHub Desktop.
RoboWhois + C# example: get the WHOIS record for a domain.
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