diff --git a/README.md b/README.md
index 7fa2058..4a3b683 100644
--- a/README.md
+++ b/README.md
@@ -43,6 +43,8 @@ Examples of API requests for different captcha types are available on the [Java
- [atbCAPTCHA](#atbcaptcha)
- [CyberSiARA](#cybersiara)
- [DataDome](#datadome)
+ - [VK Captcha](#vk-captcha)
+ - [VK Image](#vk-image)
- [Other methods](#other-methods)
- [send / getResult](#send--getresult)
- [balance](#balance)
@@ -496,6 +498,33 @@ captcha.setUserAgent("Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHT
captcha.setProxy("HTTPS", "login:password@IP_address:PORT");
```
+### 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.
+
+```java
+VkCaptcha captcha = new VkCaptcha("vkimage");
+captcha.setImageBase64(base64EncodedImage);
+captcha.setSteps("[5,12,22,24,21,23,10,7,2,8,...]");
+```
+### 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.
+
+```java
+VkCaptcha captcha = new VkCaptcha("vkcaptcha");
+captcha.setRedirectUri("https://id.vk.com/not_robot_captcha?domain=vk.com&session_token=eyJ....HGsc5B4LyvjA&variant=popup&blank=1");
+captcha.setuserAgent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36");
+captcha.setProxy("http", "1.2.3.4");
+```
+
## Other methods
### send / getResult
diff --git a/src/main/java/com/twocaptcha/ApiClient.java b/src/main/java/com/twocaptcha/ApiClient.java
index 67a877b..04ade4e 100644
--- a/src/main/java/com/twocaptcha/ApiClient.java
+++ b/src/main/java/com/twocaptcha/ApiClient.java
@@ -96,7 +96,7 @@ private String execute(Request request) throws Exception {
String body = response.body().string();
- if (body.startsWith("ERROR_")) {
+ if (body.contains("ERROR_")) {
throw new ApiException(body);
}
diff --git a/src/main/java/com/twocaptcha/captcha/Captcha.java b/src/main/java/com/twocaptcha/captcha/Captcha.java
index 523d481..5313441 100644
--- a/src/main/java/com/twocaptcha/captcha/Captcha.java
+++ b/src/main/java/com/twocaptcha/captcha/Captcha.java
@@ -64,4 +64,11 @@ public Map getFiles() {
return new HashMap<>(files);
}
+ public void setSiteKey(String siteKey) {
+ params.put("sitekey", siteKey);
+ }
+
+ public void setUrl(String url) {
+ params.put("pageurl", url);
+ }
}
diff --git a/src/main/java/com/twocaptcha/captcha/VkCaptcha.java b/src/main/java/com/twocaptcha/captcha/VkCaptcha.java
new file mode 100644
index 0000000..84f88de
--- /dev/null
+++ b/src/main/java/com/twocaptcha/captcha/VkCaptcha.java
@@ -0,0 +1,35 @@
+package com.twocaptcha.captcha;
+
+import java.io.File;
+
+public class VkCaptcha extends Captcha {
+
+ public VkCaptcha(String method) {
+ super();
+ params.put("method", method);
+ }
+
+ public void setSteps(String steps) {
+ params.put("steps", steps);
+ }
+
+ public void setImageBase64(String imageBase64) {
+ params.put("body", imageBase64);
+ }
+
+ public void setRedirectUri(String redirect_uri) {
+ params.put("redirect_uri", redirect_uri);
+ }
+
+ public void setuserAgent(String userAgent) {
+ params.put("userAgent", userAgent);
+ }
+
+ public void setFile(String filePath) {
+ setFile(new File(filePath));
+ }
+
+ public void setFile(File file) {
+ files.put("file", file);
+ }
+}
diff --git a/src/main/java/examples/VkCaptchaExample.java b/src/main/java/examples/VkCaptchaExample.java
new file mode 100644
index 0000000..a4d0ff7
--- /dev/null
+++ b/src/main/java/examples/VkCaptchaExample.java
@@ -0,0 +1,33 @@
+package examples;
+
+import com.twocaptcha.TwoCaptcha;
+import com.twocaptcha.captcha.VkCaptcha;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.Base64;
+
+public class VkCaptchaExample {
+
+ private void tokenBased(String apiKey) throws IOException {
+ TwoCaptcha solver = new TwoCaptcha(apiKey);
+ VkCaptcha captcha = new VkCaptcha("vkcaptcha");
+ captcha.setRedirectUri("https://id.vk.com/not_robot_captcha?domain=vk.com&session_token=eyJ....HGsc5B4LyvjA&variant=popup&blank=1");
+ captcha.setuserAgent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36");
+ captcha.setProxy("http", "1.2.3.4");
+
+ try {
+ solver.solve(captcha);
+ System.out.println("Captcha solved: " + captcha.getCode());
+ } catch (Exception e) {
+ System.out.println("Error occurred: " + e.getMessage());
+ }
+ }
+
+ public static void main(String[] args) throws Exception {
+ VkCaptchaExample vkExample = new VkCaptchaExample();
+ vkExample.tokenBased(args[0]);
+ }
+
+}
diff --git a/src/main/java/examples/VkImageExample.java b/src/main/java/examples/VkImageExample.java
new file mode 100644
index 0000000..46b89bf
--- /dev/null
+++ b/src/main/java/examples/VkImageExample.java
@@ -0,0 +1,37 @@
+package examples;
+
+import com.twocaptcha.TwoCaptcha;
+import com.twocaptcha.captcha.VkCaptcha;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.Base64;
+
+public class VkImageExample {
+
+ private void imageBased(String apiKey) throws IOException {
+ TwoCaptcha solver = new TwoCaptcha(apiKey);
+ solver.setExtendedResponse(1);
+
+ byte[] bytes = Files.readAllBytes(Paths.get("src/main/resources/vk.jpg"));
+ String base64EncodedImage = Base64.getEncoder().encodeToString(bytes);
+
+ VkCaptcha captcha = new VkCaptcha("vkimage");
+ captcha.setImageBase64(base64EncodedImage);
+ captcha.setSteps("[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]");
+
+ try {
+ solver.solve(captcha);
+ System.out.println("Captcha solved: " + captcha.getCode());
+ } catch (Exception e) {
+ System.out.println("Error occurred: " + e.getMessage());
+ }
+ }
+
+ public static void main(String[] args) throws Exception {
+ VkImageExample vkExample = new VkImageExample();
+ vkExample.imageBased(args[0]);
+ }
+
+}
diff --git a/src/main/resources/vk.jpg b/src/main/resources/vk.jpg
new file mode 100644
index 0000000..91809ec
Binary files /dev/null and b/src/main/resources/vk.jpg differ
diff --git a/src/test/java/com/twocaptcha/VkCaptchaTest.java b/src/test/java/com/twocaptcha/VkCaptchaTest.java
new file mode 100644
index 0000000..f0f6566
--- /dev/null
+++ b/src/test/java/com/twocaptcha/VkCaptchaTest.java
@@ -0,0 +1,26 @@
+package com.twocaptcha;
+
+import com.twocaptcha.captcha.VkCaptcha;
+import com.twocaptcha.captcha.Yandex;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class VkCaptchaTest extends AbstractWrapperTestCase {
+
+ public void testAllOptions() throws Exception {
+ VkCaptcha captcha = new VkCaptcha("vkimage");
+ captcha.setSiteKey("0x4AAAAAAAChNiVJM_WtShFf");
+ captcha.setUrl("https://ace.fusionist.io");
+
+ Map params = new HashMap<>();
+ params.put("method", "vkimage");
+ params.put("sitekey", "0x4AAAAAAAChNiVJM_WtShFf");
+ params.put("pageurl", "https://ace.fusionist.io");
+ params.put("soft_id", "4581");
+ params.put("json", "0");
+
+ checkIfCorrectParamsSendAndResultReturned(captcha, params);
+ }
+
+}
\ No newline at end of file