diff --git a/README.md b/README.md index 87afbf5..f42dc1d 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,7 @@ The easiest way to quickly integrate [2Captcha] into your code to automate solvi - [Canvas](#canvas) - [ClickCaptcha](#clickcaptcha) - [Rotate](#rotate) + - [CloudflareTurnstile](#cloudflare-turnstile) - [Lemin Cropped Captcha](#lemin-cropped-captcha) - [GeeTestV4](#geetestv4) - [Other methods](#other-methods) @@ -315,6 +316,16 @@ cap := Lemin{ } ``` +### CloudflareTurnstile +Use this method to solve Cloudflare Turnstile. Returns JSON with the token. + +```go +cap := api2captcha.CloudflareTurnstile{ + SiteKey: "0x1AAAAAAAAkg0s2VIOD34y5", + Url: "http://mysite.com/", +} +``` + ## Other methods ### Send / GetResult diff --git a/api2captcha.go b/api2captcha.go index f00cab5..ead4646 100644 --- a/api2captcha.go +++ b/api2captcha.go @@ -145,15 +145,20 @@ type ( GeeTestV4 struct { CaptchaId string - Url string + Url string } Lemin struct { CaptchaId string DivId string - Url string + Url string ApiServer string - } + } + + CloudflareTurnstile struct { + SiteKey string + Url string + } ) var ( @@ -768,7 +773,7 @@ func (c *Text) ToRequest() Request { func (c *GeeTestV4) ToRequest() Request { req := Request{ - Params: map[string]string{"method":"geetest_v4"}, + Params: map[string]string{"method": "geetest_v4"}, } if c.CaptchaId != "" { req.Params["captcha_id"] = c.CaptchaId @@ -804,3 +809,18 @@ func (c *Lemin) ToRequest() Request { } return req } + +func (c *CloudflareTurnstile) ToRequest() Request { + req := Request{ + Params: map[string]string{"method": "turnstile"}, + } + + if c.SiteKey != "" { + req.Params["sitekey"] = c.SiteKey + } + if c.Url != "" { + req.Params["pageurl"] = c.Url + } + + return req +}