3

I use Joomla 3.4.1 and Recaptcha v 2.0. I can't validate the captcha, i'm sure i've the good PHP code..

This is the code in plugin file, recaptcha.php :

function onCheckAnswer($code = null)[...]
   case '2.0':
      // Challenge Not needed in 2.0 but needed for getResponse call
      $challenge = null;
      $response  = $input->get('g-recaptcha-response', '', 'string');
      echo "response :<br>";
      var_dump($response);
      $spam      = ($response == null || strlen($response) == 0);
      echo "spam :<br>";
      var_dump($spam);
  break;

PHP code in my controller :

JPluginHelper::importPlugin('captcha');
$dispatcher = JDispatcher::getInstance();
$return = $dispatcher->trigger('onCheckAnswer');
echo "return :<br>";
var_dump($return[0]);

What this return :

response : string(0) ""

spam : bool(true)

return : bool(false)

I don't understand, someone can help me please ?

Thanks ;)

5
  • Did you create a new key to use with v2.0 of reCaptcha? The old keys won't work. Also, in the settings for the captcha plugin (Joomla backend), did you set it to v2.0?
    – Lodder
    Commented Jun 12, 2015 at 8:12
  • No, it's not specified anywhere... And yes i set v2.0 in admin ;)
    – Cotral Lab
    Commented Jun 12, 2015 at 8:48
  • I try to get new key, but the google admin of recaptcha get me the same keys for my website ;)
    – Cotral Lab
    Commented Jun 12, 2015 at 8:53
  • You're going to need to get a new key
    – Lodder
    Commented Jun 12, 2015 at 8:57
  • Ok, i've the new keys. But i doesn't work... Same problem.
    – Cotral Lab
    Commented Jun 12, 2015 at 10:17

2 Answers 2

1

I got this solved by making sure the following conditions met

  1. allow_url_fopen = On in your PHP configuration

  2. jQuery is loaded on my page, if it is not loading, your template or some plugin might be suppressing somehow. check with your template developer.

1
  • Hi thanks for your answer. "allow_url_fopen" is "On" in my PHP configuration and jQuery is loaded by Joomla (included by default). But i still have my problem....
    – Cotral Lab
    Commented Jun 15, 2015 at 7:49
0

$result = $dispatcher->trigger('onCheckAnswer',$input['recaptcha_response_field']);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.