Skip to content

Commit

Permalink
Added Cloudflare Turnstile method (#16)
Browse files Browse the repository at this point in the history
* Added Cloudflare Turnstile Captcha

* add method

---------

Co-authored-by: Badichan Polina <[email protected]>
  • Loading branch information
PBadicean and PBadicean authored Apr 27, 2023
1 parent 00d8460 commit 529439b
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 4 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
28 changes: 24 additions & 4 deletions api2captcha.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
}

0 comments on commit 529439b

Please sign in to comment.