Cakephp2.2.5 プロジェクトに recaptcha を追加する方法については、このチュートリアルに従っています。残念ながら、送信ボタンを押すたびに、コントローラーで「無効なリクエスト Cookie」エラーが発生し続けます。これが私のコントローラーのコードです
if ($this -> request -> is('post')) {
$url = 'http://www.google.com/recaptcha/api/verify';
$ch = curl_init($url);
$post = array("privatekey" => "...",
"remoteip" => $_SERVER["REMOTE_ADDR"],
"challenge"=>$this->request->data["recaptcha_challenge_field"],
"response" => $this->request->data["recaptcha_response_field"]);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($post));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
var_dump($response);
}
ajaxを使用せず、次のコードを使用する場合
$resp = recaptcha_check_answer ('...',
$_SERVER["REMOTE_ADDR"],
$this->request->data["recaptcha_challenge_field"],
$this->request->data["recaptcha_response_field"]);
$resp 変数で同じエラーが発生します。https://www.google.com/recaptcha/api/js/recaptcha_ajax.jsは既に含まれています。私も持っています
echo "<div id='recaptcha_div'></div>";
私のビューファイルで。
私はすでにフォローしようとしました
チュートリアルですが、その 1 つ以上のエラーが発生しました。だから私は簡単なチュートリアルに頼っています。どんな助けでも素晴らしいでしょう。