我已经在我的网站上使用了reCAPTCHA一段时间了,我突然意识到它已经停止工作了.reCAPTCHA在那里,但是在正确验证之后,使表单提交失败的响应FAILS.
在客户端控制台上,浏览器出错:
未捕获(承诺)无效加密.
我试图搜索此错误但找不到类似的东西.提交表单后,PHP中的服务器端验证失败.我不确定上面的错误是否相关,但之前没有.
客户端集成的示例页面:
<html>
<head>
<title>reCAPTCHA demo: Simple page</title>
<script src="https://www.google.com/recaptcha/api.js" async defer>
</script>
</head>
<body>
<form action="?" method="POST">
<div class="g-recaptcha" data-sitekey="your_site_key"></div>
<br/>
<input type="submit" value="Submit">
</form>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
服务器端验证PHP:
$response = json_decode(
file_get_contents(
"https://www.google.com/recaptcha/api/siteverifysecret=MY_SECRET&response=".$_POST['g-recaptcha-response']."&remoteip=".$_SERVER['REMOTE_ADDR'] ), true );
if($response['success'] == false){
echo "FAIL";
} else {
//do something
}
Run Code Online (Sandbox Code Playgroud)
我按照这里的说明进行操作.
为了在我们的构建和发布管道中实现版本控制,我们决定将我们的(gitversion、clean、build、tests 等)任务转移到存储在每个存储库中的蛋糕脚本来处理。
有没有办法用 cake.build 中的任务替换发布构建工件(Azure DevOps)任务?我已经搜索了 Azure 和 cake 的官方文档,但似乎找不到解决方案。第一个任务,将构建工件复制到暂存目录是可能的,但是,发布工件 - 是它变得复杂的地方。
目前,我们build.cake 的一个片段。
Task("Copy-Bin")
.WithCriteria(!isLocalBuild)
.Does(() =>
{
Information($"Creating directory {artifactStagingDir}/drop");
CreateDirectory($"{artifactStagingDir}/drop");
Information($"Copying all files from {solutionDir}/{moduleName}.ServiceHost/bin to {artifactStagingDir}/drop/bin");
CopyDirectory($"{solutionDir}/{moduleName}.ServiceHost/bin", $"{artifactStagingDir}/drop/bin");
// Now we should publish the artifact to TFS/Azure Devops
});
Run Code Online (Sandbox Code Playgroud)
解决方案
更新的 build.cake 的片段。
Task("Copy-And-Publish-Artifacts")
.WithCriteria(BuildSystem.IsRunningOnAzurePipelinesHosted)
.Does(() =>
{
Information($"Creating directory {artifactStagingDir}/drop");
CreateDirectory($"{artifactStagingDir}/drop");
Information($"Copying all files from {solutionDir}/{moduleName}.ServiceHost/bin to …Run Code Online (Sandbox Code Playgroud)