Skip to content

Commit

Permalink
RC-2363 Add new API methods (#20)
Browse files Browse the repository at this point in the history
* Added Tencent support

* Add Tencent to README.md

* Added MTCaptcha support

* Add Cutcaptcha support

* Added Friendly Captcha support

* Added atbCAPTCHA support

* Added DataDome support
  • Loading branch information
kratzky authored Jul 24, 2024
1 parent ef13477 commit ad4251e
Show file tree
Hide file tree
Showing 15 changed files with 533 additions and 5 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,7 @@ $RECYCLE.BIN/
.Trash-*

# .nfs files are created when an open file is removed but is still being accessed
.nfs*
.nfs*

# PHPUnit cache
.phpunit.result.cache
92 changes: 88 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ Examples of API requests for different captcha types are available on the [PHP c
- [Composer](#composer)
- [Manual](#manual)
- [Configuration](#configuration)
- [TwoCaptcha instance options](#twocaptcha-instance-options)
- [Solve captcha](#solve-captcha)
- [Captcha options](#captcha-options)
- [Normal Captcha](#normal-captcha)
- [Text](#text-captcha)
- [Text Captcha](#text-captcha)
- [ReCaptcha v2](#recaptcha-v2)
- [ReCaptcha v3](#recaptcha-v3)
- [FunCaptcha](#funcaptcha)
Expand All @@ -26,7 +28,7 @@ Examples of API requests for different captcha types are available on the [PHP c
- [hCaptcha](#hcaptcha)
- [KeyCaptcha](#keycaptcha)
- [Capy](#capy)
- [Grid (ReCaptcha V2 Old Method)](#grid)
- [Grid](#grid)
- [Canvas](#canvas)
- [ClickCaptcha](#clickcaptcha)
- [Rotate](#rotate)
Expand All @@ -35,14 +37,20 @@ Examples of API requests for different captcha types are available on the [PHP c
- [Lemin](#lemin)
- [Turnstile](#turnstile)
- [AmazonWaf](#amazonwaf)
- [Tencent](#tencent)
- [MTCaptcha](#mtcaptcha)
- [Cutcaptcha](#cutcaptcha)
- [Friendly Captcha](#friendly-captcha)
- [atbCAPTCHA](#atbcaptcha)
- [DataDome](#datadome)
- [Other methods](#other-methods)
- [send / getResult](#send--getresult)
- [balance](#balance)
- [report](#report)
- [Proxies](#proxies)
- [Error handling](#error-handling)
- [Get in touch](#get-in-touch)
- [Join the team 👪](#join-the-team-)
- [Get in touch](#get-in-touch)
- [Join the team 👪](#join-the-team-)


## Installation
Expand Down Expand Up @@ -249,6 +257,82 @@ $result = $solver->amazon_waf([
]);
```

### Tencent

Use this method to bypass Tencent.

```php
$result = $solver->tencent([
'sitekey' => '123456789',
'url' => 'https://www.site.com/page/',
]);
```


### MTCaptcha

Use this method to bypass MTCaptcha.

```php
$result = $solver->mt_captcha([
'sitekey' => 'MTPublic-KzqLY1cKH',
'url' => 'https://2captcha.com/demo/mtcaptcha',
]);
```

### Cutcaptcha

Use this method to bypass Cutcaptcha.

```php
$result = $solver->cutcaptcha([
'misery_key' => 'a1488b66da00bf332a1488993a5443c79047e752',
'api_key' => 'SAb83IIB',
'url' => 'https://example.cc/foo/bar.html',
]);
```

### Friendly Captcha

Use this method to bypass Friendly Captcha.

```php
$result = $solver->friendly_captcha([
'sitekey' => '2FZFEVS1FZCGQ9',
'url' => 'https://example.com/',
]);
```

### atbCAPTCHA

Use this method to bypass atbCAPTCHA.

```php
$result = $solver->atb_captcha([
'sitekey' => 'af23e041b22d000a11e22a230fa8991c',
'api_server' => 'https://cap.aisecurius.com',
'url' => 'https://example.com/',
]);
```

### DataDome

Use this method to bypass DataDome.

```php
$result = $solver->datadome([
'captcha_url' => 'af23e041b22d000a11e22a230fa8991c',
'userAgent' => 'https://cap.aisecurius.com',
'url' => 'https://example.com/',
'proxy' => [
'type' => 'HTTPS',
'uri' => 'username:str0ngP@$$W0rd@1.2.3.4:4321',
],
]);
```



## Other methods

### send / getResult
Expand Down
19 changes: 19 additions & 0 deletions examples/atb_captcha.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

set_time_limit(130);

require(__DIR__ . '/../src/autoloader.php');

$solver = new \TwoCaptcha\TwoCaptcha('YOUR_API_KEY');

try {
$result = $solver->atb_captcha([
'sitekey' => 'af23e041b22d000a11e22a230fa8991c',
'api_server' => 'https://cap.aisecurius.com',
'url' => 'https://example.com/',
]);
} catch (\Exception $e) {
die($e->getMessage());
}

die('Captcha solved: ' . $result->code);
19 changes: 19 additions & 0 deletions examples/cutcaptcha.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

set_time_limit(130);

require(__DIR__ . '/../src/autoloader.php');

$solver = new \TwoCaptcha\TwoCaptcha('YOUR_API_KEY');

try {
$result = $solver->cutcaptcha([
'misery_key' => 'a1488b66da00bf332a1488993a5443c79047e752',
'api_key' => 'SAb83IIB',
'url' => 'https://example.cc/foo/bar.html',
]);
} catch (\Exception $e) {
die($e->getMessage());
}

die('Captcha solved: ' . $result->code);
23 changes: 23 additions & 0 deletions examples/datadome.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

set_time_limit(130);

require(__DIR__ . '/../src/autoloader.php');

$solver = new \TwoCaptcha\TwoCaptcha('YOUR_API_KEY');

try {
$result = $solver->datadome([
'captcha_url' => 'https://geo.captcha-delivery.com/captcha/?initialCid=AHrlqAAA...P~XFrBVptk&t=fe&referer=https%3A%2F%2Fhexample.com&s=45239&e=c538be..c510a00ea',
'userAgent' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36',
'url' => 'https://example.com/',
'proxy' => [
'type' => 'HTTPS',
'uri' => 'username:str0ngP@$$W0rd@1.2.3.4:4321',
],
]);
} catch (\Exception $e) {
die($e->getMessage());
}

die('Captcha solved: ' . $result->code);
18 changes: 18 additions & 0 deletions examples/friendly_captcha.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

set_time_limit(130);

require(__DIR__ . '/../src/autoloader.php');

$solver = new \TwoCaptcha\TwoCaptcha('YOUR_API_KEY');

try {
$result = $solver->friendly_captcha([
'sitekey' => '2FZFEVS1FZCGQ9',
'url' => 'https://example.com/',
]);
} catch (\Exception $e) {
die($e->getMessage());
}

die('Captcha solved: ' . $result->code);
18 changes: 18 additions & 0 deletions examples/mt_captcha.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

set_time_limit(130);

require(__DIR__ . '/../src/autoloader.php');

$solver = new \TwoCaptcha\TwoCaptcha('YOUR_API_KEY');

try {
$result = $solver->mt_captcha([
'sitekey' => 'MTPublic-KzqLY1cKH',
'url' => 'https://2captcha.com/demo/mtcaptcha',
]);
} catch (\Exception $e) {
die($e->getMessage());
}

die('Captcha solved: ' . $result->code);
18 changes: 18 additions & 0 deletions examples/tencent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

set_time_limit(130);

require(__DIR__ . '/../src/autoloader.php');

$solver = new \TwoCaptcha\TwoCaptcha('YOUR_API_KEY');

try {
$result = $solver->tencent([
'sitekey' => '123456789',
'url' => 'https://www.site.com/page/',
]);
} catch (\Exception $e) {
die($e->getMessage());
}

die('Captcha solved: ' . $result->code);
110 changes: 110 additions & 0 deletions src/TwoCaptcha.php
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,110 @@ public function capy($captcha)
return $this->solve($captcha);
}

/**
* Wrapper for solving Tencent
*
* @param $captcha
* @return \stdClass
* @throws ApiException
* @throws NetworkException
* @throws TimeoutException
* @throws ValidationException
*/
public function tencent($captcha)
{
$captcha['method'] = 'tencent';

return $this->solve($captcha);
}

/**
* Wrapper for solving MTCaptcha
*
* @param $captcha
* @return \stdClass
* @throws ApiException
* @throws NetworkException
* @throws TimeoutException
* @throws ValidationException
*/
public function mt_captcha($captcha)
{
$captcha['method'] = 'mt_captcha';

return $this->solve($captcha);
}

/**
* Wrapper for solving Cutcaptcha
*
* @param $captcha
* @return \stdClass
* @throws ApiException
* @throws NetworkException
* @throws TimeoutException
* @throws ValidationException
*/
public function cutcaptcha($captcha)
{
$captcha['method'] = 'cutcaptcha';

return $this->solve($captcha);
}

/**
* Wrapper for solving Friendly Captcha
*
* @param $captcha
* @return \stdClass
* @throws ApiException
* @throws NetworkException
* @throws TimeoutException
* @throws ValidationException
*/
public function friendly_captcha($captcha)
{
$captcha['method'] = 'friendly_captcha';

return $this->solve($captcha);
}

/**
* Wrapper for solving atbCAPTCHA
*
* @param $captcha
* @return \stdClass
* @throws ApiException
* @throws NetworkException
* @throws TimeoutException
* @throws ValidationException
*/
public function atb_captcha($captcha)
{
$captcha['method'] = 'atb_captcha';

return $this->solve($captcha);
}


/**
* Wrapper for solving DataDome
*
* @param $captcha
* @return \stdClass
* @throws ApiException
* @throws NetworkException
* @throws TimeoutException
* @throws ValidationException
*/
public function datadome($captcha)
{
$captcha['method'] = 'datadome';

return $this->solve($captcha);
}


/**
* Wrapper for solving grid captcha
*
Expand Down Expand Up @@ -801,6 +905,12 @@ private function getParamsMap($method)
'capy' => [
'sitekey' => 'captchakey',
],
'tencent' => [
'sitekey' => 'app_id',
],
'atb_captcha' => [
'sitekey' => 'app_id',
],
];

if (isset($methodMap[$method])) {
Expand Down
Loading

0 comments on commit ad4251e

Please sign in to comment.