Skip to content

Instantly share code, notes, and snippets.

@weppos

weppos/gist:9461565

Created Mar 10, 2014
Embed
What would you like to do?
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
You can’t perform that action at this time.