diff --git a/README.md b/README.md
index 6105836..28f2ed9 100644
--- a/README.md
+++ b/README.md
@@ -43,6 +43,8 @@ Examples of API requests for different captcha types are available on the [PHP c
- [atbCAPTCHA](#atbcaptcha)
- [DataDome](#datadome)
- [CyberSiARA](#cybersiara)
+ - [VK Captcha](#vk-captcha)
+ - [VK Image](#vk-image)
- [Other methods](#other-methods)
- [send / getResult](#send--getresult)
- [balance](#balance)
@@ -444,6 +446,38 @@ $result = $solver->cybersiara([
]);
```
+### VK Image
+
+[API method description.](https://2captcha.com/2captcha-api#vkcaptcha)
+
+We offer two methods to solve this type of captcha - token-based and image-based.
+
+We use the body (image in base64 format) or file (image as file) and steps parameters.
+You can get both values from the response to the request https://api.vk.com/method/captchaNotRobot.getContent?v={API_VER} when loading the captcha widget on the page.
+
+```php
+ $result = $solver->vkImage([
+ 'body' => base64_encode(file_get_contents(__DIR__ . '/images/vk.jpg')),
+ 'steps' => '[5,12,22,24,21,23,10,7,2,8,19,18,8,24,21,22,11,14,16,5,18,20,4,21,12,6,0,0,11,12,8,20,19,3,14,8,9,13,16,24,18,3,2,23,8,12,6,1,11,0,20,15,19,22,17,24,8,0,12,5,19,14,11,6,7,14,23,24,23,20,4,20,6,12,4,17,4,18,6,20,17,5,23,7,10,2,8,9,5,4,17,24,11,14,4,10,12,22,21,2]',
+ ]);
+```
+### VK Captcha
+
+[API method description.](https://2captcha.com/2captcha-api#vk-captcha)
+
+Token-based method requires redirect_uri parameter, as well as proxy and userAgent. The value of the redirect_uri parameter can be found in the response to requests to the VK API that return captchas.
+
+```php
+$tokenBasedResult = $solver->vkCaptcha([
+ 'redirect_uri' => 'https://id.vk.com/not_robot_captcha?domain=vk.com&session_token=eyJ....HGsc5B4LyvjA&variant=popup&blank=1',
+ 'userAgent' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36',
+ 'proxy' => [
+ 'type' => 'HTTPS',
+ 'uri' => 'login:password@IP_address:PORT',
+ ],
+ ]);
+```
+
## Other methods
diff --git a/composer.json b/composer.json
index 6a43a4e..35c3541 100644
--- a/composer.json
+++ b/composer.json
@@ -25,7 +25,9 @@
"Cutcaptcha",
"Friendly Captcha",
"atbCAPTCHA",
- "DataDome"
+ "DataDome",
+ "vkCaptcha",
+ "vkImage"
],
"license": "MIT",
"authors": [
diff --git a/examples/images/vk.jpg b/examples/images/vk.jpg
new file mode 100644
index 0000000..91809ec
Binary files /dev/null and b/examples/images/vk.jpg differ
diff --git a/examples/rotate_options.php b/examples/rotate_options.php
index d68c2c5..2ef7f70 100644
--- a/examples/rotate_options.php
+++ b/examples/rotate_options.php
@@ -5,7 +5,7 @@
require(__DIR__ . '/../src/autoloader.php');
$solver = new \TwoCaptcha\TwoCaptcha([
- 'apiKey' => 'YOUR_API_KEY',
+ 'apiKey' => $argv[1],
'server' => 'http://2captcha.com'
]);
diff --git a/examples/text.php b/examples/text.php
index ae48d20..82b1958 100644
--- a/examples/text.php
+++ b/examples/text.php
@@ -4,7 +4,8 @@
require(__DIR__ . '/../src/autoloader.php');
-$solver = new \TwoCaptcha\TwoCaptcha('YOUR_API_KEY');
+//$argv[1] = YOUR_API_KEY
+$solver = new \TwoCaptcha\TwoCaptcha($argv[1]);
try {
$result = $solver->text('If tomorrow is Saturday, what day is today?');
diff --git a/examples/vk_captcha.php b/examples/vk_captcha.php
new file mode 100644
index 0000000..2ee0cd1
--- /dev/null
+++ b/examples/vk_captcha.php
@@ -0,0 +1,29 @@
+vkCaptcha([
+ 'redirect_uri' => 'https://id.vk.com/not_robot_captcha?domain=vk.com&session_token=eyJ....HGsc5B4LyvjA&variant=popup&blank=1',
+ 'userAgent' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36',
+ 'proxy' => [
+ 'type' => 'HTTPS',
+ 'uri' => 'login:password@IP_address:PORT',
+ ],
+ ]);
+
+ echo 'TokenBasedResult Captcha solved: ' . $tokenBasedResult->code;
+
+} catch (\Exception $e) {
+ die($e->getMessage());
+}
+
+die('Captcha solved: ' . $result->code);
diff --git a/examples/vk_image.php b/examples/vk_image.php
new file mode 100644
index 0000000..2d67c4b
--- /dev/null
+++ b/examples/vk_image.php
@@ -0,0 +1,22 @@
+vkImage([
+ 'body' => base64_encode(file_get_contents(__DIR__ . '/images/vk.jpg')),
+ 'steps' => '[5,12,22,24,21,23,10,7,2,8,19,18,8,24,21,22,11,14,16,5,18,20,4,21,12,6,0,0,11,12,8,20,19,3,14,8,9,13,16,24,18,3,2,23,8,12,6,1,11,0,20,15,19,22,17,24,8,0,12,5,19,14,11,6,7,14,23,24,23,20,4,20,6,12,4,17,4,18,6,20,17,5,23,7,10,2,8,9,5,4,17,24,11,14,4,10,12,22,21,2]',
+ ]);
+
+} catch (\Exception $e) {
+ die($e->getMessage());
+}
+
+die('Captcha solved: ' . $result->code);
diff --git a/src/TwoCaptcha.php b/src/TwoCaptcha.php
index 901796f..5373e53 100644
--- a/src/TwoCaptcha.php
+++ b/src/TwoCaptcha.php
@@ -601,6 +601,40 @@ public function cybersiara($captcha)
return $this->solve($captcha);
}
+ /**
+ * Wrapper for solving vk captcha (image)
+ *
+ * @param $captcha
+ * @return \stdClass
+ * @throws ApiException
+ * @throws NetworkException
+ * @throws TimeoutException
+ * @throws ValidationException
+ */
+ public function vkimage($captcha)
+ {
+ if (is_string($captcha)) {
+ if (!file_exists($captcha)) {
+ throw new ValidationException('File not found (' . $captcha . ')');
+ }
+ $body = file_get_contents($captcha);
+ $body = base64_encode($body);
+ $captcha = [
+ 'body' => $body,
+ ];
+ }
+
+ $captcha['method'] = 'vkimage';
+ return $this->solve($captcha);
+ }
+
+ public function vkcaptcha($captcha)
+ {
+ $captcha['method'] = 'vkcaptcha';
+
+ return $this->solve($captcha);
+ }
+
/**
* Sends captcha to `/in.php` and waits for it's result.
* This helper can be used insted of manual using of `send` and `getResult` functions.
diff --git a/tests/VkCaptchaTest.php b/tests/VkCaptchaTest.php
new file mode 100644
index 0000000..ae8b9cb
--- /dev/null
+++ b/tests/VkCaptchaTest.php
@@ -0,0 +1,34 @@
+ 'https://www.site.com/page/',
+ 'proxy' => [
+ 'type' => 'HTTPS',
+ 'uri' => 'username:str0ngP@$$W0rd@1.2.3.4:4321',
+
+ ]
+ ];
+
+ $sendParams = [
+ 'method' => 'vkcaptcha',
+ 'pageurl' => 'https://www.site.com/page/',
+ 'proxy' => 'username:str0ngP@$$W0rd@1.2.3.4:4321',
+ 'proxytype' => 'HTTPS',
+ 'soft_id' => '4585'
+ ];
+
+ $this->checkIfCorrectParamsSendAndResultReturned([
+ 'params' => $params,
+ 'sendParams' => $sendParams,
+ 'sendFiles' => [],
+ ]);
+ }
+}
diff --git a/tests/VkImageTest.php b/tests/VkImageTest.php
new file mode 100644
index 0000000..f04710f
--- /dev/null
+++ b/tests/VkImageTest.php
@@ -0,0 +1,35 @@
+ '...',
+ 'file' => $captchaImg,
+ ];
+
+ $sendParams = [
+ 'method' => 'vkimage',
+ 'body' => '...',
+ 'soft_id' => '4585',
+ ];
+
+ $sendFiles = [
+ 'file' => $captchaImg,
+ ];
+
+ $this->checkIfCorrectParamsSendAndResultReturned([
+ 'params' => $params,
+ 'sendParams' => $sendParams,
+ 'sendFiles' => $sendFiles,
+ ]);
+ }
+}