我的 reCaptcha V2“我不是機(jī)器人”在服務(wù)器端失敗。它似乎失敗了: post_captcha($_POST['g-recaptcha-response'])公鑰和 pvt 密鑰都是正確的,并且位于正確的域中。我創(chuàng)建 reCAPTCHA 已經(jīng) 3 個(gè)小時(shí)了,所以通過(guò)系統(tǒng)處理我的域可能需要一些時(shí)間?我不知道....這是 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貢獻(xiàn)1786條經(jīng)驗(yàn) 獲得超11個(gè)贊
很久沒(méi)有回答。問(wèn)題是因?yàn)槲业木W(wǎng)絡(luò)服務(wù)提供商對(duì)我訂閱的共享服務(wù)器有限制,例如無(wú)法編輯 php.ini 配置文件。
解決方案:不要使用共享服務(wù)器!
- 1 回答
- 0 關(guān)注
- 239 瀏覽
添加回答
舉報(bào)
0/150
提交
取消