L
L
Limons2021-12-05 14:16:57
C++ / C#
Limons, 2021-12-05 14:16:57

How to use the Rucaptcha API?

I can't figure out what I'm doing wrong.
Perhaps this is very rude, but the documentation for the rucaptcha CPP API is very poorly written. The examples show features that are no longer available.

Here is the error: Assertion failed: is_valid(), file C:\Users\FAS\source\repos\sovle_captha\sovle_captha\api2captcha.hpp, line 384

Here is the library: github.com/2captcha/2captcha-cpp

Here is the code:

#define CURL_STATICLIB
#include <iostream>
#include <string>
#include <curl\curl.h>
#include "api2captcha.hpp"
#include <cstdio>

using namespace std;


int main()
{
    string API_KEY = "xxx";
    

    api2captcha::client_t client;
    client.set_api_key(API_KEY);
    client.set_default_timeout(60);
    client.set_recaptcha_timeout(60);
    client.set_polling_interval(5);

    api2captcha::normal_t captcha;

    captcha.set_numeric(3);
    captcha.set_file("C:\\png\\captha\\captha.png");
    captcha.set_min_len(1);
    captcha.set_max_len(4);
    captcha.set_calc(true);
    captcha.set_lang("en");
    captcha.set_case_sensitive(false);

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

    cout << "1";
}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question