C++ Module for 2Captcha

CAPTCHAFORUM

Administrator
1655203496618.png


C++ Module for 2Captcha API
The easiest way to quickly integrate 2Captcha into your code to automate solving of any type of captcha.

Installation
The api code is a single header file api2captcha.hpp, just copy it to your project and include where needed. You need to provide a HTTP-client implementation, as there is no standard one in C++. A sample HTTP-client based on libcurl is in curl_http.hpp (libcurl v. 7.62 or higher required), include it if you are using libcurl.

Configuration
Client instance can be created like this:
api2captcha::client_t client ("YOUR_API_KEY");

There are few options that can be configured:
client.set_soft_id (123); client.set_callback ("https://your.site/result-receiver"); client.set_default_timeout (120); client.set_recaptcha_timeout (600); client.set_polling_interval (10);


1655203477617.png


Basic example
Example below shows a basic solver call example with error handling.
Code:
api2captcha::normal_t captcha;
captcha.set_file ("path/to/captcha.jpg");
captcha.set_min_len (4);
captcha.set_max_len (20);
captcha.set_case_sensitive (true);
captcha.set_lang ("en");

try
{
    client.solve (captcha);
    printf ("Captcha solved: '%s'\n", captcha.code ().c_str ());
}
catch (std::exception & e)
{
    fprintf (stderr, "Error occurred: %s\n" + e.what ());
}

Documentation https://github.com/2captcha/2captcha-cpp