cgsmith / zf1-recaptcha-2

Zend Framework 1 integration for Google reCAPTCHA version 2.0
MIT License
9 stars 11 forks source link

Site key and secret key must be specified. #18

Open sergey-leonidovich-shevchenko opened 7 years ago

sergey-leonidovich-shevchenko commented 7 years ago

I get this:

Site key and secret key must be specified.

Can you help me, please?

modules/default/forms/Registration.php $this->addElement(new \Cgsmith\Form\Element\Recaptcha());

configs/application-local.php

return [
    'recaptcha' => [
        'sitekey' => 'my site key',
        'secretkey' => 'my secret key',
    ]
];

modules/default/Bootstrap.php

public function _initView()
    {
        $view = new Zend_View();

        $view->addHelperPath(
            APPLICATION_PATH . '/../vendor/cgsmith/zf1-recaptcha-2/src/Cgsmith/View/Helper',
            'Cgsmith\\View\\Helper\\'
        );

        Zend_Controller_Action_HelperBroker::addHelper(new Zend_Controller_Action_Helper_ViewRenderer($view));

        return $view;
    }

    public function _initRecaptcha()
    {
        $config = \Zend_Registry::get('appConfig');
        $params = $config->recaptcha->toArray();

        $params['messageTemplates'] = [
            \Cgsmith\Validate\Recaptcha::INVALID_CAPTCHA => 'The captcha was invalid', // set custom/translated message
            \Cgsmith\Validate\Recaptcha::CAPTCHA_EMPTY => 'The captcha must be completed'
        ];

        \Zend_Registry::set('recaptcha', $params);
    }
cgsmith commented 7 years ago

Try this:

return [
    'recaptcha' => [
        'siteKey' => 'your site key',
        'secretKey' => 'your secret key',
    ]
];