NetTalk Central

NetTalk Web Server => Web Server - Ask For Help => Topic started by: DonRidley on June 17, 2010, 06:35:43 AM

Title: Anyone ever get a CAPTCHA to work?
Post by: DonRidley on June 17, 2010, 06:35:43 AM
I don't have Draw.  I was looking at jCap ( http://www.archreality.com/jcap/ ) but I have no idea of how to implement it.

Thanks,
Don
Title: Re: Anyone ever get a CAPTCHA to work?
Post by: bshields on June 18, 2010, 05:14:01 AM
Hi Don,

We use reCaptcha, the google one. It works nice. It requires a HTTPS Post to their webservice, but its pretty simple.

If you look at http://prdrobina.litehouse.com.au/ArticlePage?id=16 you'll see an example. The Captcha on that page doesn't behave differently irrespectively of whether the captcha is successful or not (our code knows, but i haven't built the screen to tell them they got it wrong). Also please don't play with the [Send Immediately] button as it currently sends me an SMS message each time someone clicks on [Send].

But at least you'll get the idea.

Regards
Bill
Title: Re: Anyone ever get a CAPTCHA to work?
Post by: DonRidley on June 20, 2010, 07:18:45 PM
I use a version of reCaptcha in a Joomla site.  I need a shove in the right direction as far using it with NetTalk....  please....

Thanks,
Don
Title: Re: Anyone ever get a CAPTCHA to work?
Post by: bshields on June 20, 2010, 07:57:32 PM
Hi Don,

That site is done in NT5.

You'll be familiar with the HTML required to add the Captcha, mine looks like this:

<script type="text/javascript">
var RecaptchaOptions = {theme : 'clean' };
</script>
<script src="http://api.recaptcha.net/challenge?k=***mykey***" type="text/javascript"></script>
<noscript><iframe src="http://api.recaptcha.net/noscript?k=***mykey***" height="300" width="500" frameborder="0"></iframe><br>
<textarea name="recaptcha_challenge_field" rows="3" cols="40"></textarea><input type="hidden" name="recaptcha_response_field" value="manual_challenge"></noscript>


Thats placed within a form. So in NT embed it as either XHTML or via embed point so it generates within your form.

When the form submits you'll get the following additional fields:

recaptcha_challenge_field
recaptcha_response_field


These fields require "testing" via their webserver to determine whether the user got it right or wrong.

This requires a HTTPS POST.

I wrote a quick little procedure called "PostFormResponse" to do a form POST submission.

After the form is submitted i then:

lResponse = PostFormResponse('http://api-verify.recaptcha.net/verify','privatekey=***key***&remoteip='&p_web.RequestData.FromIP&'&challenge='&CLIP(p_web.GetValue('recaptcha_challenge_field'))&'&=&response='&p_web.GetValue('recaptcha_response_field'))

lResponse holds the response from their webservice. "true" on the second line means they got it right false means they didn't.

As the webservice is HTTPS, then you need to make sure certain files are available for HTTPS to work (in NT Doco under HTTPS) I also needed to copy the CARoot.pem into the program folder.

Thats a rough outline.

Essentially:

1. Get the captcha code inside your form so the two fields it generates get submitted in the form.
2. After the form submits, but before you do anything else call their webservice and check whether it works.

The function PostFormResponse will be attached as TXA (TXT actually since it doesnt allow TXA).

Regards
Bill

[attachment deleted by admin]
Title: Re: Anyone ever get a CAPTCHA to work?
Post by: DonRidley on June 20, 2010, 10:01:32 PM
YOU are the man!! Thank you!!!
Title: Re: Anyone ever get a CAPTCHA to work?
Post by: DonRidley on June 21, 2010, 09:26:55 AM
Hey Bill,

I sent you a email reference the TXA.

Also, where do I get the CARoot.pem file?

Thanks,
Don
Title: Re: Anyone ever get a CAPTCHA to work?
Post by: Bruce on June 21, 2010, 05:55:09 PM
The caroot.pem file is in a sub directory of the big netdemo app - I suspect other places as well, but start there.

cheers
Bruce
Title: Re: Anyone ever get a CAPTCHA to work?
Post by: DonRidley on June 22, 2010, 07:55:33 AM
Thanks Bruce!
Title: Re: Anyone ever get a CAPTCHA to work?
Post by: DonRidley on June 23, 2010, 10:58:51 PM
Got it working!! Thanks Bill!!
Title: Re: Anyone ever get a CAPTCHA to work?
Post by: Alberto on June 24, 2010, 02:44:59 AM
Don,
May you please post an example app?
Thanks
Alberto
Title: Re: Anyone ever get a CAPTCHA to work?
Post by: DonRidley on June 24, 2010, 06:03:13 AM
Yes I will.  I waited for Bill's permission, because without his help, I would have never figured it out.  I'll try to get an example posted by the end of the day.