如何访问Recaptcha参数[recaptcha_challenge_field和recaptcha_response_field]?

发布于 2024-10-17 12:52:50 字数 936 浏览 2 评论 0原文

我刚开始使用 Google Recaptcha Web 服务来阻止我网站中某些网页中的垃圾邮件,并使用 AJAX 通过合并 Javascript 和 PHP 来响应我的网页来实现这一点。

我在以下链接中阅读了与其相关的所有信息,并执行了这些步骤,一切都是正确的。

Google Code recaptcha Documentation

我遇到的问题是两个验证过程中使用的字段 [recaptcha_challenge_field 和 recaptcha_response_field]

当我在 verify.php 中调用 recaptcha_check_answer 函数时,出现以下错误:-

验证码错误

这意味着 [recaptcha_challenge_field 和 recaptcha_response_field] 为 null 并且未定义。

这两个字段和变量应该具有我在其过程中使用的 reCAPTCHA PHP 库中的输入,并且应该具有 getter 来获取它们并传入提到的函数。

我在 php 文件 recaptchalib.php 中搜索了该内容,但没有找到。

我是否应该添加隐藏类型的新输入元素并使用 recaptcha_challenge_field 和 recaptcha_response_field 重命名它们以存储 recaptcha 参数?

我想知道如何以正确的方式通过它们,因为我按照指南所说的方式离开了它们,但它无法正常工作。我是否需要为它们定义新变量以及如何将它们与实际的验证码参数链接起来。

我想问谁实现了 recaptcha 并以前使用过它来告诉我如何解决这个问题,我感谢您的帮助,并提前感谢您的回答

I am new in using the Google Recaptcha Web service to block spamming in some web pages in my web site plus doing that using AJAX by merging Javascript and PHP to response to my web page.

I read all the information related to it in the following link and I carried out the steps and everything was correct.

Google Code recaptcha Documentation

The problem I faced is the two fields used in the Verification process
[recaptcha_challenge_field and recaptcha_response_field]

When I call the recaptcha_check_answer function in verify.php it gives me the following error:-

incorrect-captcha-sol

Which means that [recaptcha_challenge_field and recaptcha_response_field] are null and not defined.

These two fields and variables should have the input in the reCAPTCHA PHP library I used during its process and should have getters to have them and pass in the mentioned function.

I searched the php file recaptchalib.php for that but I did not find it.

Should I add new input elements of hidden type and rename them with recaptcha_challenge_field and recaptcha_response_field to store the recaptcha parameters ?

I wonder how I can pass them in a correct way as I leave them as the guide said but it did not work properly. Did I need to define new variables for them and how to link them with the actual recaptcha parameters.

I would like to ask who implemented recaptcha and used it before to tell me how to solve that and I appreciate your help and Thanks in advance for your answer

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

安穩 2024-10-24 12:52:50

http://code.google.com/apis/ 提供的客户端代码recaptcha/docs/php.html

require_once('recaptchalib.php');<br />
$publickey = "your_public_key"; // you got this from the signup page<br />
echo recaptcha_get_html($publickey);

扩展为:

<script type="text/javascript" src="http://www.google.com/recaptcha/api/challenge?k=your_public_key"></script>

<noscript>
    <iframe src="http://www.google.com/recaptcha/api/noscript?k=your_public_key" height="300" width="500" frameborder="0"></iframe><br/>
    <textarea name="recaptcha_challenge_field" rows="3" cols="40"></textarea>
    <input type="hidden" name="recaptcha_response_field" value="manual_challenge"/>
</noscript>

现在,我通过仅包含 noscript 标记内的行来使“noscript”版本正常工作;不是标签本身,并完全删除脚本标签及其内容。缺点是需要您在批准过程中进行手动复制粘贴。

脚本版本正在显示、刷新、接受输入等,但根据表单的目标 PHP 中的 print_r($_POST);,recaptcha_challenge_field recaptcha_response_field CGI 变量仍未设置。

所以我对上面提出的问题有了一半的解决方案。

The client-side code supplied at http://code.google.com/apis/recaptcha/docs/php.html:

require_once('recaptchalib.php');<br />
$publickey = "your_public_key"; // you got this from the signup page<br />
echo recaptcha_get_html($publickey);

expands to:

<script type="text/javascript" src="http://www.google.com/recaptcha/api/challenge?k=your_public_key"></script>

<noscript>
    <iframe src="http://www.google.com/recaptcha/api/noscript?k=your_public_key" height="300" width="500" frameborder="0"></iframe><br/>
    <textarea name="recaptcha_challenge_field" rows="3" cols="40"></textarea>
    <input type="hidden" name="recaptcha_response_field" value="manual_challenge"/>
</noscript>

Right now, I'm getting the "noscript" version to work by including only the lines inside the noscript tag; not the tag itself, and deleting the script tag and its contents entirely. Downside is that requires you to do a manual copy-paste as part of the approval process.

The script version is displaying, refreshing, accepting input, etc., but the recaptcha_challenge_field recaptcha_response_field CGI variables remain unset, according to print_r($_POST); in the target PHP of the form.

So I've got half a solution to the problem posed above.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文