Error: ' Can't use string ("") as a HASH ref while "strict refs" ' in combination with google recaptcha v2. Works on local machine but not on webhost
Error: ' Can't use string ("") as a HASH ref while "strict refs" ' in combination with google recaptcha v2. Works on local machine but not on webhost
我是 Perl 的新手,刚刚被分配了将 reCAPTCHA 更改为 reCAPTCHA v2 的快速任务。
在我的本地机器上这工作正常,但是当我将新版本的登录表单推送到虚拟主机时,该表单似乎不起作用。我收到以下错误:
AH01215:在 login_new.cgi 第 68 行第 1 行使用 "strict refs" 时,无法使用字符串 ("") 作为 HASH 引用:[......... ]
代码片段基于我在此处找到的文档:https://metacpan.org/pod/Captcha::reCAPTCHA::V2
根据错误日志,我的错误就在这里(第 68 行):
if ($submit) {
my $response = $cgi->param('g-recaptcha-response');
my $result = $captcha->verify($captcha_private_key, $response );
if ($result->{success}) # This is line 68
{....}
这让我很困惑,特别是因为它在我的本地机器上工作。能否请你帮忙?致以最诚挚的问候,并提前致谢!
验证函数有错误。我只是看了看实现。如果“$res”不是 'successful',它不会返回所需的哈希引用。
作为快速解决方法,我会检查您的 my $result
是否等于 ""
,如果是这种情况,验证功能将失败。
在很长的 运行 中,您可能应该将该错误提交给模块的创建者。
免责声明:我还没有下载该模块,只是查看了源代码而没有真正尝试我的解决方法,所以请对它持保留态度并先在安全的环境中尝试
sub verify {
my ($self, $secret, $response, $remoteip) = @_;
# ... more code here, removed for better readability
my $res = $self->{ua}->post_form(
$self->{verify_api},
$params
);
if ($res->{success}) {
my $content = decode_json $res->{content};
if ($content->{success}){
return { success => 1 };
} else {
return { success => 0, error_codes => $content->{'error-codes'} };
}
}
}
我是 Perl 的新手,刚刚被分配了将 reCAPTCHA 更改为 reCAPTCHA v2 的快速任务。
在我的本地机器上这工作正常,但是当我将新版本的登录表单推送到虚拟主机时,该表单似乎不起作用。我收到以下错误:
AH01215:在 login_new.cgi 第 68 行第 1 行使用 "strict refs" 时,无法使用字符串 ("") 作为 HASH 引用:[......... ]
代码片段基于我在此处找到的文档:https://metacpan.org/pod/Captcha::reCAPTCHA::V2
根据错误日志,我的错误就在这里(第 68 行):
if ($submit) {
my $response = $cgi->param('g-recaptcha-response');
my $result = $captcha->verify($captcha_private_key, $response );
if ($result->{success}) # This is line 68
{....}
这让我很困惑,特别是因为它在我的本地机器上工作。能否请你帮忙?致以最诚挚的问候,并提前致谢!
验证函数有错误。我只是看了看实现。如果“$res”不是 'successful',它不会返回所需的哈希引用。
作为快速解决方法,我会检查您的 my $result
是否等于 ""
,如果是这种情况,验证功能将失败。
在很长的 运行 中,您可能应该将该错误提交给模块的创建者。
免责声明:我还没有下载该模块,只是查看了源代码而没有真正尝试我的解决方法,所以请对它持保留态度并先在安全的环境中尝试
sub verify {
my ($self, $secret, $response, $remoteip) = @_;
# ... more code here, removed for better readability
my $res = $self->{ua}->post_form(
$self->{verify_api},
$params
);
if ($res->{success}) {
my $content = decode_json $res->{content};
if ($content->{success}){
return { success => 1 };
} else {
return { success => 0, error_codes => $content->{'error-codes'} };
}
}
}