#form.php
if(isset($_POST['g-recaptcha-response'])){
$captcha=$_POST['g-recaptcha-response'];
$captcha=$_GET["g-recaptcha-response"];
$response=file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=__1234__&response=".$captcha."&remoteip=".$_SERVER['REMOTE_ADDR']);
echo $response;
的回报:
注意:未定义的索引:g-recaptcha-response在/var/www/clients/qmax/app/controllers/job_application_controller.php第114行{"success": false, "error-codes": ["missing-input-response"]}
echo $response->success;
的回报:
注意:试图获得非对象的属性/var/www/clients/qmax/app/controllers/job_application_controller.php在第119行
我只需要得到"成功"对象,然后我可以测试它是真还是假,我就完成了。
删除这一行:
$captcha = $_GET["g-recaptcha-response"];
然后你需要解码json谷歌像这样:
$g_response = json_decode($response);
然后检查if/else:
if ($g_response->success === true) echo "success!";