PHP中的Recaptcha实现问题

时间:2018-07-28 06:42:23

标签: php curl recaptcha

实际上,我正在尝试实现google recaptcha,但是每当我发布表单并提交表单时,它就会显示类似:(解析错误:语法错误,意外的'['in)的问题,请帮助任何一个。

这是我的卷曲代码:

Post Site key:
 $captcha =$_POST['g-recaptcha-response']; 

curl :
    $ch = curl_init();
    curl_setopt_array($ch, [
    CURLOPT_URL => 'https://www.google.com/recaptcha/api/siteverify',
    CURLOPT_POST => true,
    CURLOPT_POSTFIELDS => [
    'secret' => '6LdxBWYUAAAAAFLN20Rnm_x6_mWv4-cWO7YXTwrw2315',
    'response' => $captcha,
    'remoteip' => $_SERVER['REMOTE_ADDR']
    ],
    CURLOPT_RETURNTRANSFER => true
    ]);
    $output = curl_exec($ch);
    //echo $output;die;
    curl_close($ch);
    $json = json_decode($output);

0 个答案:

没有答案