Hi!

I created successfully a php implementation for google recaptcha it is for 
testing purposes at the moment. I tried to implement in my cakephp dev 
enviroment (cakephp 3.0). I've just put the code into the controller. It is 
not working. I tried with the cakephp http client as well but the same 
result. I haven't got the response json.

I'm going to use my first code which is this:

$data = array(
    'secret' => '6LeXNgsTAAAAAKCN0gyrmmiqK1-h_LWIiSuwxGNo',//google 
rechapta secret-key, https://www.google.com/recaptcha
    'response' =>$this->request->data('g-recaptcha-response') //generated 
response hash
);

$url = 'https://www.google.com/recaptcha/api/siteverify';

$options = array(
   'http' => array(
       'header'  => "Content-type: application/x-www-form-urlencoded\r\n",
       'method'  => 'POST',
       'content' => http_build_query($data),
   ),
);

$context  = stream_context_create($options);
$result = file_get_contents($url, false, $context);
$result = json_decode($result, true);

print_r($result);

The above mention code works on my localhost and on my server as well but 
nor if I put into my cakephp projects controller function. Maybe I should 
put this into a model or I should create a custom class to it?

Thank you, 

Adam

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

Reply via email to