cURL Recaptcha不工作PHP [英] cURL Recaptcha not working PHP
本文介绍了cURL Recaptcha不工作PHP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有:
$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);
我得到: bool (表示
curl_exec()
失败)
:JSON对象响应
请帮助。感谢。
推荐答案
因为您尝试通过SSL连接,您需要调整您的cURL选项来处理它。如果你添加 curl_setopt($ verify,CURLOPT_SSL_VERIFYPEER,false);
Because you're attempting to connect via SSL, you need to adjust your cURL options to handle it. A quick fix to get this to work is if you add curl_setopt($verify, CURLOPT_SSL_VERIFYPEER, false);
将 CURLOPT_SSL_VERIFYPEER
设置为false将使其接受提供给它的任何证书,而不是验证它们。
Setting CURLOPT_SSL_VERIFYPEER
to false will make it so that it accepts any certificate given to it rather than 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);
这篇关于cURL Recaptcha不工作PHP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文