Golang Module for easy integration with the API of 2captcha captcha solving service to bypass recaptcha, funcaptcha, geetest and solve any other captchas.
If you call client.Solve(req), you recieve token or error.
If you have desire to report captcha task - you have to use callback parameter to receive id of each task.
Simple solution would be to return id from this method too.
My implementation of this solution:
type SolveResult struct {
ID string
Token string
}
func (c *Client) Solve(req Request) (SolveResult, error) {
if c.Callback != "" {
_, ok := req.Params["pingback"]
if !ok {
// set default pingback
req.Params["pingback"] = c.Callback
}
}
pingback, hasPingback := req.Params["pingback"]
if pingback == "" {
delete(req.Params, "pingback")
hasPingback = false
}
_, ok := req.Params["soft_id"]
if c.SoftId != 0 && !ok {
req.Params["soft_id"] = strconv.FormatInt(int64(c.SoftId), 10)
}
id, err := c.Send(req)
if err != nil {
return SolveResult{}, err
}
// don't wait for result if Callback is used
if hasPingback {
return SolveResult{
ID: id,
}, nil
}
timeout := c.DefaultTimeout
if req.Params["method"] == "userrecaptcha" {
timeout = c.RecaptchaTimeout
}
result, resultErr := c.WaitForResult(id, timeout, c.PollingInterval)
return SolveResult{ID: id, Token: result}, resultErr
}
If you call client.Solve(req), you recieve token or error. If you have desire to report captcha task - you have to use callback parameter to receive id of each task. Simple solution would be to return id from this method too.
My implementation of this solution: