Поддержка API турникетов Cloudflare
Используйте эту страницу, чтобы интегрировать решение задач турникетов с рабочим процессом API, ориентированным на совместимость.
Для более широкого контекста реализации начните с концентратора API и вернитесь сюда, чтобы просмотреть параметры и примеры, специфичные для турникетов.
Index
Каковы задачи «Турникета Cloudflare»?
Это задачи, созданные Cloudflare. Обычно они требуют от пользователя пройти процедуру проверки браузера.
Для вашего удобства мы внедрили поддержку API Turnstile. Если ваше программное обеспечение работает с ним и поддерживает минимальную конфигурацию, вы сможете декодировать турникет, используя Death By Captcha, в кратчайшие сроки.
- Turnstile API: При предоставлении URL сайта и ключа сайта Turnstile, API возвращает токен, который нужно использовать для отправки формы на странице с вызовом Turnstile.
Ценообразование
На данный момент цена составляет $2,89/1K успешно решенных вызовов Turnstile. Вам не будет выставлен счет за вызовы, которые были неверно решены. Обратите внимание, что эта цена применяется только к новым вызовам Turnstile, поэтому только клиенты, использующие этот конкретный API, будут облагаться указанной ставкой.
Часто задаваемые вопросы о TURNSTILE API:
- Какой URL API Turnstile?
-
Чтобы использовать API Turnstile, необходимо отправить запрос HTTP POST на http://api.dbcapi.me/api/captcha
- Какие параметры POST для API Turnstile?
-
- username: Имя пользователя учетной записи вашей учетной записи DBC
- password: Ваша пароль учетной записи DBC
- type=12: Тип 12 указывает, что это API Turnstile
- turnstile_params=json(payload): Данные для доступа к вызову турникета JSON Power Load Structure:
-
proxy: Ваш прокси -URL и учетные данные (если есть). Исследования:
- http://127.0.0.1:3128
- http://user:password@127.0.0.1:3128
-
proxytype: Протокол подключения вашего прокси. Для поддерживаемых типов прокси см. Какие типы прокси поддерживаются?. Пример:
- HTTP
-
sitekey: Ключ сайта Turnstile на сайте с турникетом.
Пример:
- 0x4AAAAAAAGlwMzq_9z6S9Mh
Вам нужно найти ключ сайта Turnstile. Вы можете найти элемент div Turnstile и проверить значение параметра data-sitekey или свойства sitekey внутри кода JavaScript. Также sitekey можно найти в URL iframe капчи.
- pageurl: URL-адрес страницы с вызовами турникета. Этот URL должен включать путь, в котором загружается турникет. Пример: если турникет, который вы хотите решить, находится в http://test.com/path1, то pageurl должен быть http://test.com/path1, а не http://test.com.
- action (необязательный): Значение необязательного параметра действия, который вы нашли на странице, может быть определено в атрибуте data-action или передано в вызов turnstile.render.
Параметр proxy является необязательным, но мы настоятельно рекомендуем использовать один для предотвращения отклонения на предоставленной странице из -за несоответствий между IP, который решил CAPTCHA (наша, если не предоставлен прокси) и IP, который представил Решение для проверки (ваше).
ПРИМЕЧАНИЕ: Если предоставлен прокси, прокситип является необходимым параметром.
Полный пример turnstile_params:
{ 'proxy': 'http://user:password@127.0.0.1:1234', 'proxytype': 'HTTP', 'sitekey': '0x4AAAAAAAGlwMzq_9z6S9Mh', 'pageurl': 'https://testsite.com/xxx-test' }Полный пример turnstile_params с необязательным действием параметров:
{ 'proxy': 'http://user:password@127.0.0.1:1234', 'proxytype': 'HTTP', 'sitekey': '0x4AAAAAAAGlwMzq_9z6S9Mh', 'pageurl': 'https://testsite.com/xxx-test', 'action': 'action' } - Какой ответ от API Turnstile?
-
Ответ API Turnstile имеет следующую структуру. Он действителен для одного использования и имеет срок службы 2 минуты. Он будет представлять собой строку, подобную следующей:
"0.Ja5ditqqMhsYE6r9okpFeZVg6ixDXZcbSTzxypXJkAeN-D-VxmNaEBR_XfsPG k-nxhJFUwMERSIXk6npwAifIYfKuP5AZHeLgCAm0W6CAyJlc9WvO_t7pGYnR_wwb yUyroooPkOI9mfHeeXb1urRmsTF_kP5pU5kQ05OVx3EyuXK3nl0fd4y1u7SyYThi zoKRYkLz1MOI4fHm1PHEyax3SC_IZArT2r-Uc3SXNCKj1hP-WZ3BYlRvsY5e2tUam K5cwSEqAA18u-zn0eAYJHvhqtMa3EvtQ5Q7lhLSL9JW6MOlau0uAzNmoes9yKp2Kb 6RifIyYx167waZnhSSpfFedVO3wRFtlT8AGO4ZAG1Yu60k7PIO9V8YM8s7XRCPZQ1 GEC7tWnRkPsLUqePHr1LA8GgetzbN2VxeB4.4qK44t57wfzV9awhcNrrJQ.22d19e 310e5d9f4123c5b9d52eaed2e4c4b179054eee2dd99147759975a7ab36"Используйте токен, возвращаемый в вашем взаимодействии с целевым веб-сайтом. Обычно токен отправляется через ввод с именем "cf-turnstile-response" или, когда включен режим совместимости с reCAPTCHA, также во вводе с именем "g-recaptcha-response". Также токен может быть обработан функцией обратного вызова, определенной в вызове turnstile.render или внутри атрибута data-callback.
- Какие типы прокси поддерживаются?
-
В настоящее время поддерживаются только прокси http . Поддержка других типов будет добавлена в будущем.
Использование API Turnstile с клиентами API:
/**
* Death by Captcha PHP API turnstile usage example
*
* @package DBCAPI
* @subpackage PHP
*/
/**
* DBC API clients
*/
require_once '../deathbycaptcha.php';
$username = "username"; // DBC account username
$password = "password"; // DBC account password
$token_from_panel = "your-token-from-panel"; // DBC account authtoken
// Use DeathByCaptcha_SocketClient() class if you want to use SOCKET API.
$client = new DeathByCaptcha_HttpClient($username, $password);
$client->is_verbose = true;
// To use token the first parameter must be authtoken.
// $client = new DeathByCaptcha_HttpClient("authtoken", $token_from_panel);
echo "Your balance is {$client->balance} US cents\n";
// Set the proxy and turnstile token data
$data = array(
'proxy' => 'http://user:password@127.0.0.1:1234',
'proxytype' => 'HTTP',
'sitekey' => '0x4AAAAAAAGlwMzq_9z6S9Mh',
'pageurl' => 'https://clifford.io/demo/cloudflare-turnstile'
);
//Create a json string
$json = json_encode($data);
//Put the type and the json payload
$extra = [
'type' => 12,
'turnstile_params' => $json,
];
// Put null the first parameter and add the extra payload
if ($captcha = $client->decode(null, $extra)) {
echo "CAPTCHA {$captcha['captcha']} uploaded\n";
sleep(DeathByCaptcha_Client::DEFAULT_TIMEOUT);
// Poll for CAPTCHA indexes:
if ($text = $client->get_text($captcha['captcha'])) {
echo "CAPTCHA {$captcha['captcha']} solved: {$text}\n";
// Report an incorrectly solved CAPTCHA.
// Make sure the CAPTCHA was in fact incorrectly solved!
//$client->report($captcha['captcha']);
}
}
# turnstile
import deathbycaptcha
import json
# Put your DBC account username and password here.
username = "username"
password = "password"
# you can use authtoken instead of user/password combination
# activate and get the authtoken from DBC users panel
authtoken = "authtoken"
# to use socket client
# client = deathbycaptcha.SocketClient(username, password)
# to use authtoken
# client = deathbycaptcha.SocketClient(username, password, authtoken)
client = deathbycaptcha.HttpClient(username, password)
# Put the proxy and turnstile data
Captcha_dict = {
'proxy': 'http://user:password@127.0.0.1:1234',
'proxytype': 'HTTP',
'sitekey': '0x4AAAAAAAGlwMzq_9z6S9Mh',
'pageurl': 'https://clifford.io/demo/cloudflare-turnstile'
}
# Create a json string
json_Captcha = json.dumps(Captcha_dict)
try:
balance = client.get_balance()
print(balance)
# Put your CAPTCHA type and Json payload here:
captcha = client.decode(type=12, turnstile_params=json_Captcha)
if captcha:
# The CAPTCHA was solved; captcha["captcha"] item holds its
# numeric ID, and captcha["text"] its text token solution.
print("CAPTCHA %s solved: %s" % (captcha["captcha"], captcha["text"]))
if '': # check if the CAPTCHA was incorrectly solved
client.report(captcha["captcha"])
except deathbycaptcha.AccessDeniedException:
# Access to DBC API denied, check your credentials and/or balance
print("error: Access to DBC API denied, check your credentials and/or balance")
import com.DeathByCaptcha.AccessDeniedException;
import com.DeathByCaptcha.Client;
import com.DeathByCaptcha.HttpClient;
import com.DeathByCaptcha.SocketClient;
import com.DeathByCaptcha.Captcha;
import org.json.JSONObject;
import java.io.IOException;
class ExampleTurnstile {
public static void main(String[] args)
throws Exception {
// Put your DBC username & password or authtoken here:
String username = "your_username_here";
String password = "your_password_here";
String authtoken = "your_authtoken_here";
/* Death By Captcha Socket Client
Client client = (Client) (new SocketClient(username, password));
Death By Captcha http Client */
Client client = (Client) (new HttpClient(username, password));
client.isVerbose = true;
/* Using authtoken
Client client = (Client) new HttpClient(authtoken); */
try {
try {
System.out.println("Your balance is " + client.getBalance()
+ " US cents");
} catch (IOException e) {
System.out.println("Failed fetching balance: " + e.toString());
return;
}
Captcha captcha = null;
try {
// Proxy and turnstile data
String proxy = "http://user:password@127.0.0.1:1234";
String proxytype = "http";
String sitekey = "0x4AAAAAAAGlwMzq_9z6S9Mh";
String pageurl = "https://clifford.io/demo/cloudflare-turnstile";
/* Upload a turnstile and poll for its status with 120 seconds timeout.
Put your proxy, proxy type, page sitekey, page url and solving
timeout (in seconds) 0 or nothing for the default timeout value. */
captcha = client.decode(12, proxy, proxytype, sitekey, pageurl);
//other method is to send a json with the parameters
/*
JSONObject json_params = new JSONObject();
json_params.put("proxy", proxy);
json_params.put("proxytype", proxytype);
json_params.put("sitekey", sitekey);
json_params.put("pageurl", pageurl);
captcha = client.decode(12, json_params);
*/
} catch (IOException e) {
System.out.println("Failed uploading CAPTCHA");
return;
}
if (null != captcha) {
System.out.println("CAPTCHA " + captcha.id + " solved: "
+ captcha.text);
/* Report incorrectly solved CAPTCHA if necessary.
Make sure you've checked if the CAPTCHA was in fact incorrectly
solved, or else you might get banned as abuser. */
/*try {
if (client.report(captcha)) {
System.out.println("Reported as incorrectly solved");
} else {
System.out.println(
"Failed reporting incorrectly solved CAPTCHA");
}
} catch (IOException e) {
System.out.println(
"Failed reporting incorrectly solved CAPTCHA:" + e.toString());
}*/
} else {
System.out.println("Failed solving CAPTCHA");
}
} catch (com.DeathByCaptcha.Exception e) {
System.out.println(e);
}
}
}
// turnstile
using System;
using System.Collections;
using DeathByCaptcha;
namespace DBC_Examples.examples
{
public class Turnstile Example
{
public void Main()
{
// Put your DeathByCaptcha account username and password here.
string username = "your username";
string password = "your password";
// string token_from_panel = "your-token-from-panel";
/* Death By Captcha Socket Client
Client client = (Client) new SocketClient(username, password);
Death By Captcha http Client */
Client client = (Client) new HttpClient(username, password);
/* To use token authentication the first parameter must
be "authtoken".
Client client = (Client) new HttpClient("authtoken",
token_from_panel); */
// Put your Proxy credentials and type here
string proxy = "http://user:password@127.0.0.1:1234";
string proxyType = "HTTP";
string sitekey = "0x4AAAAAAAGlwMzq_9z6S9Mh";
string pageurl = "https://clifford.io/demo/cloudflare-turnstile";
string turnstileParams = "{\"proxy\": \"" + proxy + "\"," +
"\"proxytype\": \"" + proxyType + "\"," +
"\"sitekey\": \"" + sitekey + "\"," +
"\"pageurl\": \"" + pageurl + "\"}";
try
{
double balance = client.GetBalance();
/* Upload a CAPTCHA and poll for its status. Put the Turnstile
Json payload, CAPTCHA type and desired solving timeout
(in seconds) here. If solved, you'll receive a
DeathByCaptcha.Captcha object. */
Captcha captcha = client.Decode(Client.DefaultTimeout,
new Hashtable()
{
{"type", 12},
{"turnstile_params", turnstileParams}
});
if (null != captcha)
{
/* The CAPTCHA was solved; captcha.Id property holds
its numeric ID, and captcha.Text holds its text. */
Console.WriteLine("CAPTCHA {0} solved: {1}",
captcha.Id, captcha.Text);
// if ( /* check if the CAPTCHA was incorrectly solved */)
// {
// client.Report(captcha);
// }
}
}
catch (AccessDeniedException e)
{
/* Access to DBC API denied,
check your credentials and/or balance */
Console.WriteLine("<<< catch : " + e.ToString());
}
}
}
}
Imports DeathByCaptcha
Public Class Turnstile
Sub Main(args As String())
' Put your DBC username & password or authtoken here:
Dim username = "username"
Dim password = "password"
Dim token_from_panel = "your-token-from-panel"
' DBC Socket API client
' Dim client As New SocketClient(username, password)
' DBC HTTP API client
Dim client As New HttpClient(username, password)
' To use token auth the first parameter must be "authtoken"
' Dim client As New HttpClient("authtoken", token_from_panel)
' Proxy and turnstile data
Dim proxy = "http://user:password@127.0.0.1:1234"
Dim proxyType = "HTTP"
Dim sitekey = "0x4AAAAAAAGlwMzq_9z6S9Mh"
Dim pageurl = "https://clifford.io/demo/cloudflare-turnstile"
Console.WriteLine(String.Format("Your balance is {0,2:f} US cents",
client.Balance))
' Create a JSON with the extra data
Dim turnstileParams = "{""proxy"": """ + proxy + """," +
"""proxytype"": """ + proxyType + """," +
"""sitekey"": """ + sitekey + """," +
"""pageurl"": """ + pageurl + """}"
' Create the payload with the type and the extra data
Dim extraData As New Hashtable()
extraData.Add("type", 12)
extraData.Add("turnstile_params", turnstileParams)
' Upload a CAPTCHA and poll for its status. Put the Turnstile
' Json payload, CAPTCHA type and desired solving timeout (in seconds)
' here. If solved, you'll receive a DeathByCaptcha.Captcha object.
Dim captcha As Captcha = client.Decode(
DeathByCaptcha.Client.DefaultTimeout, extraData)
If captcha IsNot Nothing Then
Console.WriteLine(String.Format("CAPTCHA {0:d} solved: {1}",
captcha.Id, captcha.Text))
' Report an incorrectly solved CAPTCHA.
' Make sure the CAPTCHA was in fact incorrectly solved, do not
' just report it at random, or you might be banned as abuser.
' If client.Report(captcha) Then
' Console.WriteLine("Reported as incorrectly solved")
' Else
' Console.WriteLine("Failed reporting as incorrectly solved")
' End If
End If
End Sub
End
/*
* Death by Captcha Node.js API turnstile usage example
*/
const dbc = require('../deathbycaptcha');
const username = 'username'; // DBC account username
const password = 'password'; // DBC account password
const token_from_panel = 'your-token-from-panel'; // DBC account authtoken
// Proxy and turnstile token data
const turnstile_params = JSON.stringify({
'proxy': 'http://username:password@proxy.example:3128',
'proxytype': 'HTTP',
'sitekey': '0x4AAAAAAAGlwMzq_9z6S9Mh',
'pageurl': 'https://clifford.io/demo/cloudflare-turnstile'
});
// Death By Captcha Socket Client
// const client = new dbc.SocketClient(username, password);
// Death By Captcha http Client
const client = new dbc.HttpClient(username, password);
// To use token authentication the first parameter must be "authtoken"
// const client = new dbc.HttpClient("authtoken", token_from_panel);
// Get user balance
client.get_balance((balance) => {
console.log(balance);
});
// Solve captcha with type 12 & turnstile_params extra arguments
client.decode({extra: {type: 12, turnstile_params: turnstile_params}},
(captcha) => {
if (captcha) {
console.log('Captcha ' + captcha['captcha'] + ' solved: '
+ captcha['text']);
/*
* Report an incorrectly solved CAPTCHA.
* Make sure the CAPTCHA was in fact incorrectly solved!
* client.report(captcha['captcha'], (result) => {
* console.log('Report status: ' + result);
* });
*/
}
});
Следующий шаг реализации
После проверки параметров турникета и обработки токенов используйте ссылки на цены и надежность для окончательного принятия решений о развертывании производства.

Russian
English
Spanish
Chinese
French
Hindi
Arabic
Bengali
Indonesian
Portuguese









com, 