我的 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 回答
- 0 關注
- 230 瀏覽
添加回答
舉報
0/150
提交
取消