Skip to content

Commit c903a80

Browse files
authored
add friendly captcha fixes #30 (#31)
1 parent bed3952 commit c903a80

File tree

4 files changed

+89
-4
lines changed

4 files changed

+89
-4
lines changed

README.md

+14-4
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
The easiest way to quickly integrate [2Captcha] into your code to automate solving of any types of captcha.
1212
Examples of API requests for different captcha types are available on the [C# captcha solver](https://2captcha.com/lang/csharp) page.
1313

14-
- [C# Module for 2Captcha API (captcha solver)](#c-module-for-2captcha-api-captcha-solver)
14+
- [C# Module for 2Captcha API (captcha solver)](#c-module-for-2captcha-api-captcha-solver)
1515
- [Installation](#installation)
1616
- [Configuration](#configuration)
1717
- [TwoCaptcha instance options](#twocaptcha-instance-options)
@@ -37,16 +37,17 @@ Examples of API requests for different captcha types are available on the [C# ca
3737
- [Lemin](#lemin)
3838
- [Turnstile](#turnstile)
3939
- [AmazonWaf](#amazonwaf)
40+
- [Friendly Captcha](#friendly-captcha)
4041
- [Other methods](#other-methods)
4142
- [send / getResult](#send--getresult)
4243
- [balance](#balance)
4344
- [report](#report)
4445
- [Proxies](#proxies)
4546
- [Error handling](#error-handling)
46-
- [Get in touch](#get-in-touch)
47-
- [Join the team 👪](#join-the-team-)
47+
- [Get in touch](#get-in-touch)
48+
- [Join the team 👪](#join-the-team-)
4849
- [License](#license)
49-
- [Graphics and Trademarks](#graphics-and-trademarks)
50+
- [Graphics and Trademarks](#graphics-and-trademarks)
5051

5152
## Installation
5253
Install nuget package from [nuget]
@@ -343,6 +344,15 @@ captcha.SetContext("test_iv");
343344
captcha.SetIV("test_context");
344345
```
345346

347+
### Friendly Captcha
348+
Use this method to solve Friendly Captcha. Returns a token to bypass the captcha.
349+
350+
```csharp
351+
FriendlyCaptcha captcha = new FriendlyCaptcha();
352+
captcha.SetSiteKey("2FZFEVS1FZCGQ9");
353+
captcha.SetUrl("https://example.com");
354+
```
355+
346356

347357
## Other methods
348358

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using System;
2+
using System.Linq;
3+
using TwoCaptcha.Captcha;
4+
5+
namespace TwoCaptcha.Examples
6+
{
7+
public class FriendlyCaptchaExample
8+
{
9+
public void Main()
10+
{
11+
TwoCaptcha solver = new TwoCaptcha("YOUR_API_KEY");
12+
13+
FriendlyCaptcha captcha = new FriendlyCaptcha();
14+
captcha.SetSiteKey("2FZFEVS1FZCGQ9");
15+
captcha.SetUrl("https://example.com");
16+
17+
try
18+
{
19+
solver.Solve(captcha).Wait();
20+
Console.WriteLine("Captcha solved: " + captcha.Code);
21+
}
22+
catch (AggregateException e)
23+
{
24+
Console.WriteLine("Error occurred: " + e.InnerExceptions.First().Message);
25+
}
26+
}
27+
}
28+
}
+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using System.Collections.Generic;
2+
using System.Threading.Tasks;
3+
using NUnit.Framework;
4+
using TwoCaptcha.Captcha;
5+
6+
namespace TwoCaptcha.Tests
7+
{
8+
[TestFixture]
9+
public class FriendlyCaptchaTest : AbstractWrapperTestCase
10+
{
11+
[Test]
12+
public async Task TestAllOptions()
13+
{
14+
FriendlyCaptcha captcha = new FriendlyCaptcha();
15+
captcha.SetSiteKey("2FZFEVS1FZCGQ9");
16+
captcha.SetUrl("https://www.site.com/page/");
17+
18+
var parameters = new Dictionary<string, string>();
19+
parameters["method"] = "friendly_captcha";
20+
parameters["sitekey"] = "2FZFEVS1FZCGQ9";
21+
parameters["pageurl"] = "https://www.site.com/page/";
22+
parameters["soft_id"] = "4582";
23+
24+
await CheckIfCorrectParamsSendAndResultReturned(captcha, parameters);
25+
}
26+
}
27+
}

TwoCaptcha/Captcha/FriendlyCaptcha.cs

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
namespace TwoCaptcha.Captcha
2+
{
3+
public class FriendlyCaptcha : Captcha
4+
{
5+
public FriendlyCaptcha() : base()
6+
{
7+
parameters["method"] = "friendly_captcha";
8+
}
9+
10+
public void SetSiteKey(string siteKey)
11+
{
12+
parameters["sitekey"] = siteKey;
13+
}
14+
15+
public void SetUrl(string url)
16+
{
17+
parameters["pageurl"] = url;
18+
}
19+
}
20+
}

0 commit comments

Comments
 (0)