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