我拼命試圖讓我的表單工作。問題與recaptcha 2.0 php服務器端
但我遇到了驗證recaptcha服務器端的問題。
我一直在環顧四周,一遍又一遍地測試我的表格,我知道它沒有通過recaptcha的步驟,但無法弄清楚。
這裏是我的一段代碼:
//variable :
$recaptcha = $_POST['g-recaptcha-response'];
//test captcha
if($recaptcha != '')
{
$secret = " MY KEY HERE";
$ip = $_SERVER['REMOTE_ADDR'];
$var = file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=".$secret."&response=".$recaptcha."&remoteip=".$ip);
$array = json_decode($var,true);
//check if captcha ok then check fields empty
if($array['success'])
請讓我知道,如果你能發現任何錯誤。
謝謝。 (確實我刪除了我的安全密鑰)
犯錯,不是請求,API假設是POST請求? – frz3993
你是什麼意思? – Cenafor
根據[doc](https://developers.google.com/recaptcha/docs/verify),您正在執行GET請求。該方法應該是POST。 – frz3993