Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
5725375
Add new Ancticaptcha service
m-tymchyk Aug 18, 2016
7358ed4
Add PHP Docs
m-tymchyk Aug 18, 2016
ebe4e2d
Update Composer JSON
m-tymchyk Aug 18, 2016
fc2f12c
Update Composer
m-tymchyk Aug 18, 2016
82f9053
Updates
m-tymchyk Aug 18, 2016
a5ddab5
Fix .gitignore file
m-tymchyk Aug 18, 2016
cb8c4b0
Fix cosmetics error
m-tymchyk Aug 18, 2016
52e5983
Rename Namespaces
m-tymchyk Aug 18, 2016
2732bdb
Fix codestyle
m-tymchyk Aug 19, 2016
68896c3
Update Readmy.MD
m-tymchyk Aug 24, 2016
80054ac
fix class names references
jenyak Sep 21, 2016
1b91bf7
Rename ExceptionAnticaptcha.php to ExceptionAntiCaptcha.php
jenyak Sep 21, 2016
58de581
Merge pull request #1 from jenyak/master
m-tymchyk Sep 21, 2016
04cb697
Update README.md
m-tymchyk Sep 22, 2016
3255509
Update AntiCaptcha.php
m-tymchyk Sep 22, 2016
9b1ab95
Update Rucaptcha.php
m-tymchyk Sep 22, 2016
90db8f1
Update Exception Logging
m-tymchyk Dec 2, 2016
bf60ca4
Fix Loggers errors, when debug=false
m-tymchyk Dec 2, 2016
2f42681
Update composer.json
m-tymchyk Dec 9, 2016
4c2deef
Падает если debug mode выключен
keanor Jul 12, 2017
260ed9a
Merge pull request #3 from keanor/patch-1
m-tymchyk Sep 29, 2017
f228762
Refactore code and Code style
m-tymchyk Apr 5, 2018
101e2f7
Update readme.MD
m-tymchyk Jan 22, 2019
a0994aa
Update
m-tymchyk Jan 22, 2019
ae05c65
Update to be compatible with PHP7.0 and PHP7.1
m-tymchyk Jan 22, 2019
b7a5251
Update README.md
m-tymchyk Mar 9, 2019
f4f9117
Update guzzlehttp/guzzle to v7.0.1, php 7.2
Apr 19, 2021
304b931
Merge pull request #1 from RoboFinance/guzzle_v7
flexnst Apr 19, 2021
5f86ee2
Merge pull request #5 from RoboFinance/guzzle_v7
m-tymchyk Apr 19, 2021
5c496fd
Remove version from composer.json for using tags
Apr 19, 2021
d5bffb6
Merge pull request #6 from RoboFinance/master
m-tymchyk Apr 19, 2021
910a6e8
Major update to v2.0.0 / Add support of reCaptcha V2
m-tymchyk Oct 13, 2022
de642ed
Update Readme
m-tymchyk Oct 13, 2022
6b6d577
Implement reCaptcha V2 Enterprise and V3 task solving
m-tymchyk Apr 27, 2023
8e670b7
Actualise Readme
m-tymchyk Apr 28, 2023
5a5a139
Add support of Turnstile
m-tymchyk Apr 28, 2023
5722618
Fix Readme texts
m-tymchyk Apr 28, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Created by .ignore support plugin (hsz.mobi)
### Example user template template
### Example user template

# IntelliJ project files
.idea
.idea/misc.xml
.idea/vcs.xml

*.iml
out
gen
vendor/
5 changes: 2 additions & 3 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2015
Copyright (c) 2016

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand All @@ -18,5 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

SOFTWARE.
230 changes: 227 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,229 @@
# php-anticaptcha
<p align="center">
<h1 align="center">Anticaptcha PHP SDK</h1>

PHP client for Anticaptcha services.
<p align="center">
This library will help you to recognize any captcha via specific services.<br>
Easy to install. Easy to use.
<br/>
<br/>
<a href="https://packagist.org/packages/reilag/php-anticaptcha">packages.org</a>
·
<a href="http://getcaptchasolution.com/zi0d4paljn">anti-captcha.com</a>
</p>
</p>

See examples in the folder example.
---

[![Total Downloads](https://poser.pugx.org/reilag/php-anticaptcha/downloads)](https://packagist.org/packages/reilag/php-anticaptcha)
[![License](https://poser.pugx.org/reilag/php-anticaptcha/license)](https://packagist.org/packages/reilag/php-anticaptcha)
[![Latest Stable Version](https://poser.pugx.org/reilag/php-anticaptcha/v/stable)](https://packagist.org/packages/reilag/php-anticaptcha)

---


PHP client for [anti-captcha.com](http://getcaptchasolution.com/zi0d4paljn) service.
This client supports resolving captcha types:
- [Captcha from image](#recognize-captcha-from-image)
- [reCaptcha V2](#recognize-recaptcha-v2-with-proxy-or-without-invisible)
- [Invisible reCaptcha](#recognize-recaptcha-v2-with-proxy-or-without-invisible)
- [reCaptcha V2 Enterprise](#recognize-recaptcha-v2-enterprise-with-proxy-or-without)
- [reCaptcha V3](#recognize-captcha-from-image)
- [reCaptcha V3 Enterprise](#recognize-recaptcha-v3-or-v3-enterprise)
- [Turnstile](#recognize-turnstile)

To Do:
- FunCaptcha
- GeeTest captcha
- Solving HCaptcha


### Install

You can add Anticaptcha as a dependency using the **composer.phar** CLI:
```bash
# Install Composer (if need)
curl -sS https://getcomposer.org/installer | php

# Add dependency
composer require reilag/php-anticaptcha:^2.2.0
```


After installing, you need to require Composer's autoloader:
```php
require 'vendor/autoload.php';
```

You can find some examples at [/example](/example) path.

### Create Client
```php
use AntiCaptcha\AntiCaptcha;

// Your API key
$apiKey = '*********** API_KEY **************';

$antiCaptchaClient = new AntiCaptcha(
AntiCaptcha::SERVICE_ANTICAPTCHA,
[
'api_key' => $apiKey,
'debug' => true
]
);
```



### Recognize captcha from image

```php
use AntiCaptcha\AntiCaptcha;

// Get file content
$image = file_get_contents(realpath(dirname(__FILE__)) . '/images/image.jpg');

$imageText = $antiCaptchaClient->recognizeImage($image, null, ['phrase' => 0, 'numeric' => 0], 'en');

echo $imageText;
```



### Recognize reCaptcha V2 (with Proxy or without, Invisible)

```php
$task = new \AntiCaptcha\Task\RecaptchaV2Task(
"http://makeawebsitehub.com/recaptcha/test.php", // <-- target website address
"6LfI9IsUAAAAAKuvopU0hfY8pWADfR_mogXokIIZ" // <-- recaptcha key from target website
);

// Value of 'data-s' parameter. Applies only to Recaptchas on Google web sites.
$task->setRecaptchaDataSValue("some data s-value")

// Specify whether or not reCaptcha is invisible. This will render an appropriate widget for our workers.
$task->setIsInvisible(true);

// To use Proxy, use this function
$task->setProxy(
"8.8.8.8",
1234,
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116",
"http",
"login",
"password",
// also you can add cookie
"cookiename1=cookievalue1; cookiename2=cookievalue2"
);

$response = $antiCaptchaClient->recognizeTask($task);

echo $response['gRecaptchaResponse'];
```


### Recognize reCaptcha V2 Enterprise (with Proxy or without)

```php
$task = new \AntiCaptcha\Task\RecaptchaV2EnterpriseTask(
"http://makeawebsitehub.com/recaptcha/test.php", // <-- target website address
"6LfI9IsUAAAAAKuvopU0hfY8pWADfR_mogXokIIZ" // <-- recaptcha key from target website
);

// Additional array parameters enterprisePayload
$task->setEnterprisePayload([
"s" => "SOME_ADDITIONAL_TOKEN"
]);

// To use Proxy
$task->setProxy(
"8.8.8.8",
1234,
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116",
"http",
"login",
"password",
// also you can add cookie
"cookiename1=cookievalue1; cookiename2=cookievalue2"
);

$response = $antiCaptchaClient->recognizeTask($task);

echo $response['gRecaptchaResponse'];
```



### Recognize reCaptcha V3 (or V3 Enterprise)

```php
$task = new \AntiCaptcha\Task\RecaptchaV3Task(
"http://makeawebsitehub.com/recaptcha/test.php", // target website address
"6LfI9IsUAAAAAKuvopU0hfY8pWADfR_mogXokIIZ", // recaptcha key from target website

// Filters workers with a particular score. It can have one of the following values:
// 0.3, 0.7, 0.9
"0.3"
);

// Recaptcha's "action" value. Website owners use this parameter to define what users are doing on the page.
$task->setPageAction("myaction");

// As V3 Enterprise is virtually the same as V3 non-Enterprise, we decided to roll out it’s support within the usual V3 tasks.
// Set this flag to "true" if you need this V3 solved with Enterprise API. Default value is "false" and
// Recaptcha is solved with non-enterprise API.
$reCaptchaV3Task->setIsEnterprise(true);

$response = $antiCaptchaClient->recognizeTask($task);

echo $response['gRecaptchaResponse']; // Return 3AHJ_VuvYIBNBW5yyv0zRYJ75VkOKvhKj9_xGBJKnQimF72rfoq3Iy-DyGHMwLAo6a3
```



### Recognize Turnstile

```php
$task = new \AntiCaptcha\Task\TurnstileTask(
// Address of a target web page. Can be located anywhere on the web site, even in a member area.
// Our workers don't navigate there but simulate the visit instead.
"http://makeawebsitehub.com/recaptcha/test.php",
// Turnstile sitekey
"6LfI9IsUAAAAAKuvopU0hfY8pWADfR_mogXokIIZ"
);

// Optional "action" parameter.
$task->setAction("myaction");

// If you need setup proxy
$task->setProxy(
"8.8.8.8",
1234,
"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Firefox/102.0",
"http",
"login",
"password",
null // also you can add cookie
);

$response = $antiCaptchaClient->recognizeTask($task);

// Token string required for interacting with the submit form on the target website.
echo $response['token']; // 0.vtJqmZnvobaUzK2i2PyKaSqHELYtBZfRoPwMvLMdA81WL_9G0vCO3y2VQVIeVplG0mxYF7uX.......

// User-Agent of worker's browser. Use it when you submit the response token.
echo $response['userAgent']; // Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Firefox/102.0
```



### Get balance
```php
use AntiCaptcha\AntiCaptcha;

$apiKey = '*********** API_KEY **************';

$service = new \AntiCaptcha\Service\AntiCaptcha($apiKey);
$antiCaptchaClient = new \AntiCaptcha\AntiCaptcha($service);

echo "Your Balance is: " . $antiCaptchaClient->balance() . "\n";
```
23 changes: 14 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
{
"name": "sidcomua/php-anticaptcha",
"name": "reilag/php-anticaptcha",
"version": "2.2.0",
"type": "library",
"description": "Anticaptcha",
"keywords": ["anticaptcha", "php", "antigate", "rucaptcha"],
"homepage": "https://github.com/sidcomua/php-anticaptcha",
"description": "AntiCaptcha - Is PHP Library for working with Anticapthca services",
"keywords": ["php", "anticaptcha", "anti-captcha", "antigate", "rucaptcha"],
"homepage": "https://github.com/reilag/php-anticaptcha",
"license": "MIT",
"authors": [
{
"name" : "SID"
"name": "Tymchyk Maksym",
"email": "reilag69@gmail.com"
}
],
"require": {
"php": ">=5.4.0",
"guzzlehttp/guzzle": ">=6",
"psr/log": "~1"
"php": ">=7.2.6",
"guzzlehttp/guzzle": "^7.0.1",
"psr/log": "~1",
"ext-json": "*"
},
"autoload": {
"classmap": ["src/"]
"psr-4": {
"AntiCaptcha\\": "src/"
}
}
}
Loading