I use Blogengine and want to add Recaptcha v2 from Billkrat. In RecaptchaValidator.cs we find the following code:
public RecaptchaResponse Validate()
{
CheckNotNull(this.PrivateKey, "PrivateKey");
CheckNotNull(this.RemoteIP, "RemoteIp");
CheckNotNull(this.Challenge, "Challenge");
CheckNotNull(this.Response, "Response");
if (this.Challenge == string.Empty || this.Response == string.Empty)
{
return RecaptchaResponse.InvalidSolution;
}
var request = (HttpWebRequest)WebRequest.Create(VerifyUrl);
// to avoid issues with Expect headers
request.ProtocolVersion = HttpVersion.Version10;
request.Timeout = 30 * 1000 /* 30 seconds */;
request.Method = "POST";
request.UserAgent = "reCAPTCHA/ASP.NET";
request.ContentType = "application/x-www-form-urlencoded";
var formdata = String.Format(
HttpUtility.UrlEncode(this.PrivateKey),
HttpUtility.UrlEncode(this.Response),
HttpUtility.UrlEncode(this.RemoteIP));
var formbytes = Encoding.ASCII.GetBytes(formdata);
try
{
using (var requestStream = request.GetRequestStream())
{
requestStream.Write(formbytes, 0, formbytes.Length);
}
dynamic results;
using (var httpResponse = request.GetResponse())
{
var httpResponseStream = httpResponse.GetResponseStream();
if (httpResponseStream == null)
{
return RecaptchaResponse.RecaptchaNotReachable;
}
using (TextReader readStream = new StreamReader(httpResponseStream, Encoding.UTF8))
{
results = JObject.Parse(readStream.ReadToEnd());
}
}
And Google always returns the error 'missing-input-secret'. Any hint is appreciated.