0
我得到这个错误与验证码:问题的验证码和.NET
'Input error: response: Required field must not be blank
challenge: Required field must not be blank
privatekey: Required field must not be blank'
我通过POST发送数据,所以我不明白是怎么回事。这是我使用的代码:
public static Boolean Check(String challenge, String response)
{
try
{
String privatekey = "7LeAbLoSAAAABJBn05uo6sZoFNoFnK2XKyF3dRXL";
String remoteip = HttpContext.Current.Request.UserHostAddress;
WebRequest req = WebRequest.Create("http://api-verify.recaptcha.net/verify");
req.Method = "POST";
using (StreamWriter sw = new StreamWriter(req.GetRequestStream()))
{
sw.Write("privatekey={0}&remoteip={1}&challenge={2}&response={3}", privatekey, remoteip, challenge, response);
sw.Flush();
}
String resultString = String.Empty;
String errorString = String.Empty;
using (StreamReader sr = new StreamReader(req.GetResponse().GetResponseStream()))
{
resultString = sr.ReadLine();
errorString = sr.ReadLine();
}
Boolean b;
return Boolean.TryParse(resultString, out b) && b;
}
catch (Exception)
{
return false;
}
}
(当然that'is不正确的私有密钥:P)
我不知道问题是什么,我想我发送数据正确,但那个错误说,显然我没有发送任何东西。
可能是什么问题?
干杯。
为什么不使用您在http://code.google.com/p/recaptcha上找到的社区支持的开源实现,而不是编写自己的实现。 – 2010-05-26 13:58:45
因为使用插件是非常简单的事情:D .NET的插件是用于ASP.NET的,我没有使用ASP.NET。 无论如何,我喜欢自己做这些事情:P – vtortola 2010-05-26 14:17:48