Skip to content

Commit 4a7182d

Browse files
authored
Optional params (#24)
* added additional parameters * updated tests * updated readme
1 parent 7ed0541 commit 4a7182d

File tree

7 files changed

+86
-45
lines changed

7 files changed

+86
-45
lines changed

README.md

+53-45
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,37 @@
11
# C# Module for 2Captcha API
22
The easiest way to quickly integrate [2Captcha] into your code to automate solving of any types of captcha.
33

4-
- [Installation](#installation)
5-
- [Configuration](#configuration)
6-
- [Solve captcha](#solve-captcha)
7-
- [Normal Captcha](#normal-captcha)
8-
- [Text](#text-captcha)
9-
- [ReCaptcha v2](#recaptcha-v2)
10-
- [ReCaptcha v3](#recaptcha-v3)
11-
- [FunCaptcha](#funcaptcha)
12-
- [GeeTest](#geetest)
13-
- [GeeTestV4](#geetestv4)
14-
- [hCaptcha](#hcaptcha)
15-
- [KeyCaptcha](#keycaptcha)
16-
- [Capy](#capy)
17-
- [Grid (ReCaptcha V2 Old Method)](#grid)
18-
- [Canvas](#canvas)
19-
- [ClickCaptcha](#clickcaptcha)
20-
- [Rotate](#rotate)
21-
- [Audio](#audio)
22-
- [Yandex](#yandex)
23-
- [Lemin](#lemin)
24-
- [Turnstile](#turnstile)
25-
- [AmazonWaf](#amazonwaf)
26-
- [Other methods](#other-methods)
27-
- [send / getResult](#send--getresult)
28-
- [balance](#balance)
29-
- [report](#report)
30-
- [Error handling](#error-handling)
4+
- [C# Module for 2Captcha API](#c-module-for-2captcha-api)
5+
- [Installation](#installation)
6+
- [Configuration](#configuration)
7+
- [TwoCaptcha instance options](#twocaptcha-instance-options)
8+
- [Solve captcha](#solve-captcha)
9+
- [Captcha options](#captcha-options)
10+
- [Basic example](#basic-example)
11+
- [Normal Captcha](#normal-captcha)
12+
- [Text Captcha](#text-captcha)
13+
- [ReCaptcha v2](#recaptcha-v2)
14+
- [ReCaptcha v3](#recaptcha-v3)
15+
- [FunCaptcha](#funcaptcha)
16+
- [GeeTest](#geetest)
17+
- [GeeTestV4](#geetestv4)
18+
- [hCaptcha](#hcaptcha)
19+
- [KeyCaptcha](#keycaptcha)
20+
- [Capy](#capy)
21+
- [Grid](#grid)
22+
- [Canvas](#canvas)
23+
- [ClickCaptcha](#clickcaptcha)
24+
- [Rotate](#rotate)
25+
- [Audio](#audio)
26+
- [Yandex](#yandex)
27+
- [Lemin](#lemin)
28+
- [Turnstile](#turnstile)
29+
- [AmazonWaf](#amazonwaf)
30+
- [Other methods](#other-methods)
31+
- [send / getResult](#send--getresult)
32+
- [balance](#balance)
33+
- [report](#report)
34+
- [Error handling](#error-handling)
3135

3236
## Installation
3337
Install nuget package from [nuget]
@@ -48,13 +52,13 @@ solver.PollingInterval = 10;
4852

4953
### TwoCaptcha instance options
5054

51-
|Option|Default value|Description|
52-
|---|---|---|
53-
|softId|-|your software ID obtained after publishing in [2captcha sofware catalog]|
54-
|callback|-|URL of your web-sever that receives the captcha recognition result. The URl should be first registered in [pingback settings] of your account|
55-
|defaultTimeout|120|Polling timeout in seconds for all captcha types except ReCaptcha. Defines how long the module tries to get the answer from `res.php` API endpoint|
56-
|recaptchaTimeout|600|Polling timeout for ReCaptcha in seconds. Defines how long the module tries to get the answer from `res.php` API endpoint|
57-
|pollingInterval|10|Interval in seconds between requests to `res.php` API endpoint, setting values less than 5 seconds is not recommended|
55+
| Option | Default value | Description |
56+
| ---------------- | ------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- |
57+
| softId | - | your software ID obtained after publishing in [2captcha sofware catalog] |
58+
| callback | - | URL of your web-sever that receives the captcha recognition result. The URl should be first registered in [pingback settings] of your account |
59+
| defaultTimeout | 120 | Polling timeout in seconds for all captcha types except ReCaptcha. Defines how long the module tries to get the answer from `res.php` API endpoint |
60+
| recaptchaTimeout | 600 | Polling timeout for ReCaptcha in seconds. Defines how long the module tries to get the answer from `res.php` API endpoint |
61+
| pollingInterval | 10 | Interval in seconds between requests to `res.php` API endpoint, setting values less than 5 seconds is not recommended |
5862

5963
> **IMPORTANT:** once `Callback` is defined for `TwoCaptcha` instance, all methods return only the captcha ID and DO NOT poll the API to get the result. The result will be sent to the callback URL.
6064
To get the answer manually use [getResult method](#send--getresult)
@@ -63,17 +67,17 @@ To get the answer manually use [getResult method](#send--getresult)
6367
When you submit any image-based captcha use can provide additional options to help 2captcha workers to solve it properly.
6468

6569
### Captcha options
66-
|Option|Default Value|Description|
67-
|---|---|---|
68-
|numeric|0|Defines if captcha contains numeric or other symbols [see more info in the API docs][post options]|
69-
|minLength|0|minimal answer lenght|
70-
|maxLength|0|maximum answer length|
71-
|phrase|0|defines if the answer contains multiple words or not|
72-
|caseSensitive|0|defines if the answer is case sensitive|
73-
|calc|0|defines captcha requires calculation|
74-
|lang|-|defines the captcha language, see the [list of supported languages] |
75-
|hintImg|-|an image with hint shown to workers with the captcha|
76-
|hintText|-|hint or task text shown to workers with the captcha|
70+
| Option | Default Value | Description |
71+
| ------------- | ------------- | -------------------------------------------------------------------------------------------------- |
72+
| numeric | 0 | Defines if captcha contains numeric or other symbols [see more info in the API docs][post options] |
73+
| minLength | 0 | minimal answer lenght |
74+
| maxLength | 0 | maximum answer length |
75+
| phrase | 0 | defines if the answer contains multiple words or not |
76+
| caseSensitive | 0 | defines if the answer is case sensitive |
77+
| calc | 0 | defines captcha requires calculation |
78+
| lang | - | defines the captcha language, see the [list of supported languages] |
79+
| hintImg | - | an image with hint shown to workers with the captcha |
80+
| hintText | - | hint or task text shown to workers with the captcha |
7781

7882
Below you can find basic examples for every captcha type. Check out [examples directory] to find more examples with all available options.
7983

@@ -194,6 +198,7 @@ Use this method to solve hCaptcha challenge. Returns a token to bypass captcha.
194198
HCaptcha captcha = new HCaptcha();
195199
captcha.SetSiteKey("10000000-ffff-ffff-ffff-000000000001");
196200
captcha.SetUrl("https://www.site.com/page/");
201+
captcha.SetData("foo");
197202
captcha.SetProxy("HTTPS", "login:password@IP_address:PORT");
198203
```
199204

@@ -307,6 +312,9 @@ Use this method to solve Turnstile and obtain a token to bypass the protection.
307312
Turnstile captcha = new Turnstile();
308313
captcha.SetSiteKey("0x4AAAAAAAChNiVJM_WtShFf");
309314
captcha.SetUrl("https://ace.fusionist.io");
315+
captcha.SetData("foo");
316+
captcha.SetPageData("bar");
317+
captcha.SetAction("baz");
310318
```
311319

312320
### AmazonWaf

TwoCaptcha.Tests/HCaptchaTest.cs

+2
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@ public async Task TestAllOptions()
1414
HCaptcha captcha = new HCaptcha();
1515
captcha.SetSiteKey("f1ab2cdefa3456789012345b6c78d90e");
1616
captcha.SetUrl("https://www.site.com/page/");
17+
captcha.SetData("foo");
1718

1819
var parameters = new Dictionary<string, string>();
1920
parameters["method"] = "hcaptcha";
2021
parameters["sitekey"] = "f1ab2cdefa3456789012345b6c78d90e";
2122
parameters["pageurl"] = "https://www.site.com/page/";
23+
parameters["data"] = "foo";
2224

2325
await CheckIfCorrectParamsSendAndResultReturned(captcha, parameters);
2426
}

TwoCaptcha.Tests/ReCaptchaTest.cs

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public async Task TestV2()
1818
captcha.SetInvisible(true);
1919
captcha.SetAction("verify");
2020
captcha.SetDomain("recaptcha.net");
21+
captcha.SetDataS("foo");
2122

2223
var parameters = new Dictionary<string, string>();
2324
parameters["method"] = "userrecaptcha";
@@ -26,6 +27,7 @@ public async Task TestV2()
2627
parameters["invisible"] = "1";
2728
parameters["action"] = "verify";
2829
parameters["domain"] = "recaptcha.net";
30+
parameters["data-s"] = "foo";
2931

3032
await CheckIfCorrectParamsSendAndResultReturned(captcha, parameters);
3133
}

TwoCaptcha.Tests/TurnstileTest.cs

+6
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,17 @@ public async Task TestAllOptions()
1414
Turnstile captcha = new Turnstile();
1515
captcha.SetSiteKey("0x4AAAAAAAChNiVJM_WtShFf");
1616
captcha.SetUrl("https://ace.fusionist.io");
17+
captcha.SetData("foo");
18+
captcha.SetPageData("bar");
19+
captcha.SetAction("baz");
1720

1821
var parameters = new Dictionary<string, string>();
1922
parameters["method"] = "turnstile";
2023
parameters["sitekey"] = "0x4AAAAAAAChNiVJM_WtShFf";
2124
parameters["pageurl"] = "https://ace.fusionist.io";
25+
parameters["data"] = "foo";
26+
parameters["pagedata"] = "bar";
27+
parameters["action"] = "baz";
2228

2329
await CheckIfCorrectParamsSendAndResultReturned(captcha, parameters);
2430
}

TwoCaptcha/Captcha/HCaptcha.cs

+5
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,10 @@ public void SetUrl(string url)
1616
{
1717
parameters["pageurl"] = url;
1818
}
19+
20+
public void SetData(string data)
21+
{
22+
parameters["data"] = data;
23+
}
1924
}
2025
}

TwoCaptcha/Captcha/ReCaptcha.cs

+5
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,10 @@ public void SetEnterprise(bool invisible)
4848
{
4949
parameters["enterprise"] = invisible ? "1" : "0";
5050
}
51+
52+
public void SetDataS(string data)
53+
{
54+
parameters["data-s"] = data;
55+
}
5156
}
5257
}

TwoCaptcha/Captcha/Turnstile.cs

+13
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,18 @@ public void SetUrl(string url)
1616
{
1717
parameters["pageurl"] = url;
1818
}
19+
20+
public void SetAction(string action)
21+
{
22+
parameters["action"] = action;
23+
}
24+
public void SetData(string data)
25+
{
26+
parameters["data"] = data;
27+
}
28+
public void SetPageData(string pagedata)
29+
{
30+
parameters["pagedata"] = pagedata;
31+
}
1932
}
2033
}

0 commit comments

Comments
 (0)