ReCaptcha Code Script 2


SUBMITTED BY: rajesh93

DATE: Feb. 16, 2017, 9:32 a.m.

UPDATED: Feb. 16, 2017, 9:33 a.m.

FORMAT: Text only

SIZE: 983 Bytes

HITS: 1071

  1. local response = http.request({url='http://www.google.com/recaptcha/api/verify',
  2. method='post',
  3. data={
  4. privatekey = '<YOUR PRIVATE KEY HERE>',
  5. remoteip = request.remote_addr,
  6. challenge = request.form.challenge,
  7. response = request.form.response
  8. }}).content
  9. local firstline = response:match('[^\n]*')
  10. if firstline == 'true' then
  11. -- CAPTCHA passed. Do things here.
  12. return { success=true }
  13. else
  14. -- CAPTCHA failed.
  15. return { success=false }
  16. end
  17. $('#recaptchaButton').click(function (e) {
  18. e.preventDefault();
  19. $.post('https://examples.webscript.io/recaptcha',
  20. { challenge: Recaptcha.get_challenge(), response:Recaptcha.get_response() },
  21. function (data) {
  22. if (data.success) {
  23. alert("Captcha completed successfully!");
  24. loadCaptcha();
  25. } else {
  26. alert("Captcha failed.");
  27. }
  28. });
  29. });

comments powered by Disqus