Forum Moderators: open
<script type="text/javascript"
src="http://www.google.com/recaptcha/api/challenge?k=mypublickey">
</script>
<noscript>
<iframe src="http://www.google.com/recaptcha/api/noscript?k=mypublickey"
height="250" width="500" frameborder="0"></iframe><br>
<textarea name="x" rows="3" cols="40">
</textarea>
<input type="hidden" name="recaptcha_response_field"
value="manual_challenge">
</noscript> string response1 = Request["recaptcha_response_field"];
string challenge1 = Request["recaptcha_challenge_field"];
string privatekey1 = "myprivatekey";
string remoteip1 = Request.ServerVariables["REMOTE_ADDR"];
Uri address = new Uri("http://www.google.com/recaptcha/api/verify");
// Create the web request
HttpWebRequest request = WebRequest.Create(address) as HttpWebRequest;
// Set type to POST
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
// Create the data we want to send
StringBuilder data = new StringBuilder();
data.Append("&response=" + HttpUtility.UrlEncode(response1));
data.Append("&challenge=" + HttpUtility.UrlEncode(challenge1));
data.Append("&privatekey=" + HttpUtility.UrlEncode(privatekey1));
data.Append("&remoteip=" + HttpUtility.UrlEncode(remoteip1));
// Create a byte array of the data we want to send
byte[] byteData = UTF8Encoding.UTF8.GetBytes(data.ToString());
// Set the content length in the request headers
request.ContentLength = byteData.Length;
// Write data
using (Stream postStream = request.GetRequestStream())
{
postStream.Write(byteData, 0, byteData.Length);
}
// Get response
using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
{
// Get the response stream
StreamReader reader = new StreamReader(response.GetResponseStream());
// Console application output
Label1.Text = reader.ReadToEnd();
}