cURL Recaptcha not working PHP -


what have:

$data = array(             'secret' => "my-app-secret",             'response' => "the-response"         );  $verify = curl_init(); curl_setopt($verify, curlopt_url, "https://www.google.com/recaptcha/api/siteverify"); curl_setopt($verify, curlopt_post, true); curl_setopt($verify, curlopt_postfields, http_build_query($data)); curl_setopt($verify, curlopt_returntransfer, true); $response = curl_exec($verify);  var_dump($response); 

what got: bool(false) (which means curl_exec() failed)

what expect: json object response

please help. thanks.

because you're attempting connect via ssl, need adjust curl options handle it. quick fix work if add curl_setopt($verify, curlopt_ssl_verifypeer, false);

setting curlopt_ssl_verifypeer false make accepts certificate given rather verifying them.

<?php  $data = array(             'secret' => "my-secret",             'response' => "my-response"         );  $verify = curl_init(); curl_setopt($verify, curlopt_url, "https://www.google.com/recaptcha/api/siteverify"); curl_setopt($verify, curlopt_post, true); curl_setopt($verify, curlopt_postfields, http_build_query($data)); curl_setopt($verify, curlopt_ssl_verifypeer, false); curl_setopt($verify, curlopt_returntransfer, true); $response = curl_exec($verify);  var_dump($response); 

Comments

Popular posts from this blog

java - Andrioid studio start fail: Fatal error initializing 'null' -

android - Gradle sync Error:Configuration with name 'default' not found -

StringGrid issue in Delphi XE8 firemonkey mobile app -