Reputation: 125
I'm trying to use the new ReCaptcha code on a simple form.
I've signed up with one domain, the one required for the live version of the form.
I've got the form to display the ReCaptcha box fine... at first I just had to tick the box, now as I keep using it, it prompts to enter the displayed text. This suggests it's working correctly.
The problem is getting the response at submit.
If I enter the URL by hand
https://www.google.com/recaptcha/api/siteverify?secret={0}&response={1}
...where {0} is my secret key and {1} is the result of Request.Form("g-recaptcha-response") then it works.
If I use this code (pinched from t'net):
Dim GoogleReply = Client.DownloadString(String.Format("https://www.google.com/recaptcha/api/siteverify?secret={0}&response={1}", PrivateKey, EncodedResponse))
...then it stalls with a timeout.
Is there anything wrong with the code? Or anything further I need to do to let the server side code get a response?
Upvotes: 0
Views: 2092
Reputation: 125
I've used Steve's code (see above) and also found I needed to use a proxy to allow the in-code request to get through to the web.... so I've added some additional code (the extra variables area all assigned from the web.config)
If Trim(strUseJHProxy) = "1" Then
Dim proxy As New System.Net.WebProxy(strJHProxyURL, False)
proxy.Credentials = New System.Net.NetworkCredential(strNetworkUserName, strNetworkUserPassword, strNetworkUserDomain)
request.Proxy = proxy
End If
It's now working :) Thanks Steve!
Upvotes: 1