在本文中,我们尽量回答了所有关键问题。要开始解决问题,第一步是确定当前使用的是哪种防护系统。为此,您可以查看常见验证码与反机器人防护系统列表,其中提供了可视化示例和关键特征,帮助您快速判断自己正在使用哪一种方案。
如果您发现自己的网站使用的是 Prosopo Procaptcha,下一步就是更深入地了解它的特性和具体工作方式。在本文中,您还可以查看 Prosopo Procaptcha 的接入说明,以便彻底弄清它在您的网站上是如何运行的。这样一来,您不仅能更好地理解当前的防护机制,还可以更合理地规划后续的维护和支持。
测试包含 Prosopo Procaptcha 的表单时,常常需要确认 captcha 是否集成正确并工作正常。
你可以手动验证站点上的 captcha。
若想自动解题,可以使用 CapMonster Cloud 等服务,它会接收验证码参数、在服务器中解析并返回可直接使用的 token。把 token 注入表单即可无需人工操作通过验证。
通过 CapMonster Cloud API 工作的一般流程:
type - ProsopoTask
websiteURL - 验证码页面的完整 URL;
websiteKey - 页面中找到的 siteKey 值。
https://api.capmonster.cloud/createTask
{
"clientKey": "API_KEY",
"task": {
"type": "ProsopoTask",
"websiteURL": "https://www.example.com",
"websiteKey": "5EZU3LG31uzq1Mwi8inwqxmfvFDpj7VzwDnZwj4Q3syyxBwV"
}
}
{
"errorId":0,
"taskId":407533072
}https://api.capmonster.cloud/getTaskResult{
"clientKey":"API_KEY",
"taskId": 407533072
}
{
"errorId":0,
"status":"ready",
"solution": {
"token": "0x00016c68747470733a2f2f70726f6e6f6465332e70726f736f706f2e696fc0354550516f4d5a454463354c704e376774784d4d7a5950547a4136..."
}
}
async function sendTokenToSite(token) {
// 表单 URL 或 endpoint,用于提交令牌
const formURL = "https://example..com/en/your-form-endpoint";
// 表单数据示例
const formData = {
email: "example@example.com",
password: "yourpassword",
"procaptcha-response": token // 来自 Procaptcha 的令牌
};
try {
const response = await fetch(formURL, {
method: "POST",
headers: {
"Content-Type": "application/json", // или 'application/x-www-form-urlencoded' 视网站而定
},
body: JSON.stringify(formData),
});
const result = await response.text(); // 或 response.json() 如果服务器返回 JSON
console.log("Server response:", result);
} catch (err) {
console.error("Error sending token:", err);
}
}
// 主函数
async function solveAndSend() {
const client = CapMonsterCloudClientFactory.Create(
new ClientOptions({ clientKey: API_KEY })
);
const prosopoRequest = new ProsopoRequest({
websiteURL: "https://example.com/en/",
websiteKey: "5EZU3LG31uzq1Mwi8inwqxmfvFDpj7VzwDnZwj4Q3syyxBwV"
});
const balance = await client.getBalance();
console.log("Balance:", balance);
const result = await client.Solve(prosopoRequest);
console.log("Captcha solution:", result);
// 提交令牌到网站
await sendTokenToSite(result.solution); // result.solution 包含 Procaptcha 令牌
}
solveAndSend().catch(console.error);
1. 获取密钥(sitekey 和 secret key)
2. 添加您的域名
3. 连接 Procaptcha 脚本
将标签放置在 <head>
<script type="module" src="https://js.prosopo.io/js/procaptcha.bundle.js" async defer></script>>4. 方案 1: 隐式渲染(自动) — 简单
添加容器,使验证码自动显示:
<div class="procaptcha" data-sitekey="your_site_key"></div>通常放在表单内部。
<html>
<head>
<title>Procaptcha Demo</title>
<script type="module" src="https://js.prosopo.io/js/procaptcha.bundle.js" async defer></script>
</head>
<body>
<form action="" method="POST">
<input type="text" name="email" placeholder="Email" />
<input type="password" name="password" placeholder="Password" />
<div class="procaptcha" data-sitekey="your_site_key"></div>
<br />
<input type="submit" value="Submit" />
</form>
</body>
</html>验证成功后,将添加隐藏参数:
5. 方案 2: 显式渲染(手动) — 控制更多
<html>
<head>
<script
type="module"
id="procaptcha-script"
src="https://js.prosopo.io/js/procaptcha.bundle.js"
async
defer
></script>
</head>
<body>
<div id="procaptcha-container"></div>
</body>
</html>
document.getElementById('procaptcha-script').addEventListener('load', function () {
function onCaptchaVerified(output) {
console.log('Captcha verified, output: ' + JSON.stringify(output))
}
const captchaContainer = document.getElementById('procaptcha-container')
window.procaptcha.render(captchaContainer, {
siteKey: 'YOUR_SITE_KEY',
theme: 'dark',
callback: onCaptchaVerified,
})
})6. 配置验证码类型(可选)
可以明确选择:
例如:
<div class="procaptcha"
data-sitekey="your_site_key"
data-captcha-type="pow">
</div>7. 必需步骤:服务器验证令牌
渲染验证码后,服务器 必须 验证响应。通过 API 进行验证:
https://api.prosopo.io/siteverify请求内容:
{
"secret": "your_secret_key",
"token": "PROCAPTCHA-RESPONSE"
}8. PHP 服务器验证
<?php
function verifyToken($token) {
$url = 'https://api.prosopo.io/siteverify';
$data = json_encode(["secret" => "your_secret_key", "token" => $token]);
$options = [
'http' => [
'header' => "Content-Type: application/json\r\n",
'method' => 'POST',
'content' => $data,
],
];
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
$response = json_decode($result, true);
return $response["verified"] ?? false;
}
?>什么算验证成功?
如果 Procaptcha 服务器返回:
{
"verified": true
}— 验证码通过,可以执行受保护操作(例如注册用户)。
如果你接手了一个已经集成了验证码或其他防护系统的网站,但又无法访问其代码,也不用担心!要判断实际使用了哪种技术其实并不难。为了核实其是否正常工作,你可以在隔离的测试环境中使用CapMonster Cloud识别服务,确保令牌处理机制和校验逻辑都运行正常。
对于Prosopo Procaptcha,只需识别出所用的系统,观察其行为,并确认防护是否正常工作即可。本文演示了如何识别 Prosopo Procaptcha,以及到哪里查找其接入或重新配置的说明文档,从而帮助你自信地维护防护方案并掌控其运行情况。