亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

reCAPTCHA V2 服務器端驗證失敗

reCAPTCHA V2 服務器端驗證失敗

PHP
qq_笑_17 2023-06-18 16:03:42
我的 reCaptcha V2“我不是機器人”在服務器端失敗。它似乎失敗了: post_captcha($_POST['g-recaptcha-response'])公鑰和 pvt 密鑰都是正確的,并且位于正確的域中。我創建 reCAPTCHA 已經 3 個小時了,所以通過系統處理我的域可能需要一些時間?我不知道....這是 HTML:<html><head>  <script src="https://www.google.com/recaptcha/api.js" async defer></script></head><body><form action="contact-form.php" method="POST">  <div class="g-recaptcha" data-sitekey="PUBLIC KEY"></div>  <br/>  <input type="submit" value="Submit"></form></body></html>這是PHP:<?php// Checks if form has been submittedif ($_SERVER['REQUEST_METHOD'] == 'POST') {    function post_captcha($user_response) {        $fields_string = '';        $fields = array(            'secret' => 'PVT KEY',            'response' => $user_response        );        foreach($fields as $key=>$value)        $fields_string .= $key . '=' . $value . '&';        $fields_string = rtrim($fields_string, '&');        $ch = curl_init();        curl_setopt($ch, CURLOPT_URL, 'https://www.google.com/recaptcha/api/siteverify');        curl_setopt($ch, CURLOPT_POST, count($fields));        curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string);        curl_setopt($ch, CURLOPT_RETURNTRANSFER, True);        $result = curl_exec($ch);        curl_close($ch);        return json_decode($result, true);    }    // Call the function post_captcha    $res = post_captcha($_POST['g-recaptcha-response']);    if (!$res['success']) {        // What happens when the CAPTCHA wasn't checked        echo '<p>Please go back and make sure you check the security CAPTCHA box.</p><br>';    } else {        echo 'success';    }}?>任何幫助將不勝感激!謝謝。
查看完整描述

1 回答

?
Qyouu

TA貢獻1786條經驗 獲得超11個贊

很久沒有回答。問題是因為我的網絡服務提供商對我訂閱的共享服務器有限制,例如無法編輯 php.ini 配置文件。

解決方案:不要使用共享服務器!


查看完整回答
反對 回復 2023-06-18
  • 1 回答
  • 0 關注
  • 230 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號