【发布时间】:2017-06-15 06:19:21
【问题描述】:
我正在尝试在https://www.google.com/recaptcha/api/siteverify 上验证我的$_POST['g-recaptcha-response'],但我不断得到以下结果:
"success": false,
"error-codes": [
"missing-input-response",
"missing-input-secret"
]
我的代码:
if($has_errors == false) {
$result = file_get_contents( 'https://www.google.com/recaptcha/api/siteverify', false, stream_context_create( array(
'http' => array(
'header' => "Content-type: application/x-www-form-urlencoded\r\n",
'method' => 'POST',
'content' => http_build_query( array(
'response' => $_POST['g-recaptcha-response'],
'secret' => variable_get('google_recaptcha_secret', '')
) ),
),
) ) );
var_dump($result);
$result = json_decode($result);
if($result->success == false) {
form_set_error('name', t('Submission blocked by Google Invisible Captcha.'));
}
}
我检查了我的变量google_recaptcha_secret,它是正确的。
【问题讨论】: