ezcaptcha

package module
v0.0.0-...-b82d423 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 18, 2024 License: BSD-2-Clause Imports: 7 Imported by: 0

README

EzCaptcha Client Go

Supported Captchas

  • AkamaiWeb
  • AkamaiBMP
  • HCaptcha + Enterprise
  • ReCaptchaV2 + Enterprise
  • ReCaptchaV3 + Enterprise

Installing

go get -u autoace.su/samjblack/ezcaptcha-client-go

Usage

client, err := ezcaptcha.NewClient("your-api-key", "", 0)
if err != nil {
    log.Fatal(err)
}
task, err := client.NewReCaptchaV2Task(&ezcaptcha.ReCaptchaV2{
// For availabe types please refer to ezcaptcha's docs (https://ezcaptcha.atlassian.net/wiki/spaces/IS/pages/7045121/EzCaptcha+API+Docs+English)
    Type:        "ReCaptchaV2TaskProxyless",
    WebsiteURL:  "https://www.google.com/recaptcha/api2/demo",
    WebsiteKey:  "6Le-wvkSAAAAAPBMRTvw0Q4Muexq9bi0DJwx_mJ-",
    IsInvisible: false,
})
if err != nil {
    log.Fatal(err)
}
result, err := client.GetResult(task)
if err != nil {
    log.Fatal(err)
}
fmt.Println(result.Solution.GRecaptchaResponse)     

AkamaiBMP Example

client, err := ezcaptcha.NewClient("your-api-key", "", 0)
if err != nil {
    log.Fatal(err)
}
result, err := client.SolveAkamaiBMP(&ezcaptcha.AkamaiBMP{
    Type:     "AkamaiBMPTaskProxyless",
    BundleID: "example.bundle.id",
    Device:   "ios",
    Version:  "3.3.5",
})
if err != nil {
    log.Fatal(err)
}
fmt.Println(result.Solution.Sensor)

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ApiURL                 string = "https://api.ez-captcha.com"
	SyncApiURL             string = "https://sync.ez-captcha.com"
	CreateTaskEndPoint     string = "/createTask"
	CreateSyncTaskEndpoint string = "/createSyncTask"
	GetTaskResultEndPoint  string = "/getTaskResult"
	GetBalanceEndPoint     string = "/getBalance"
)

Functions

This section is empty.

Types

type Akamai

type Akamai struct {
	Type    string `json:"type"`
	PageURL string `json:"pageUrl"`
	Bmsz    string `json:"bmsz"`
	UA      string `json:"ua"`
	Lang    string `json:"lang"`
}

type AkamaiBMP

type AkamaiBMP struct {
	Type     string `json:"type"`
	BundleID string `json:"bundleID"`
	Device   string `json:"device"`
	Version  string `json:"version"`
}

type AkamaiResponse

type AkamaiResponse struct {
	ErrorID          int `json:"errorId"`
	ErrorCode        any `json:"errorCode,omitempty"`
	ErrorDescription any `json:"errorDescription,omitempty"`
	Solution         struct {
		Payload string `json:"payload,omitempty"`
		Sensor  string `json:"sensor,omitempty"`
	} `json:"solution"`
	Status string `json:"status"`
}

type Client

type Client struct {
	ClientKey string `json:"clientKey"`
	AppID     string `json:"appId,omitempty"`
	Attempts  int
}

func NewClient

func NewClient(clientKey, appID string, attempts int) (*Client, error)

func (*Client) GetBalance

func (c *Client) GetBalance() (int, error)

func (*Client) GetResult

func (c *Client) GetResult(task *CreateTaskResponse) (*SolutionResponse, error)

func (*Client) NewHCaptchaTask

func (c *Client) NewHCaptchaTask(task *HCaptcha) (*CreateTaskResponse, error)

func (*Client) NewReCaptchaV2Task

func (c *Client) NewReCaptchaV2Task(task *ReCaptchaV2) (*CreateTaskResponse, error)

func (*Client) NewReCaptchaV3Task

func (c *Client) NewReCaptchaV3Task(task *ReCaptchaV3) (*CreateTaskResponse, error)

func (*Client) SolveAkamai

func (c *Client) SolveAkamai(task *Akamai) (*AkamaiResponse, error)

func (*Client) SolveAkamaiBMP

func (c *Client) SolveAkamaiBMP(task *AkamaiBMP) (*AkamaiResponse, error)

type CreateTaskResponse

type CreateTaskResponse struct {
	ErrorID          int    `json:"errorId"`
	ErrorCode        string `json:"errorCode,omitempty"`
	ErrorDescription string `json:"errorDescription,omitempty"`
	TaskID           string `json:"taskId,omitempty"`
}

type GetBalanceRequest

type GetBalanceRequest struct {
	ClientKey string `json:"clientKey"`
}

type GetBalanceResponse

type GetBalanceResponse struct {
	Balance          int `json:"balance,omitempty"`
	ErrorID          int `json:"errorId"`
	ErrorCode        any `json:"errorCode,omitempty"`
	ErrorDescription any `json:"errorDescription,omitempty"`
}

type HCaptcha

type HCaptcha struct {
	Type              string `json:"type"`
	WebsiteURL        string `json:"websiteURL"`
	WebsiteKey        string `json:"websiteKey"`
	EnterpricePayload string `json:"enterprisePayload,omitempty"`
	IsInvisible       bool   `json:"isInvisible,omitempty"`
}

type ReCaptchaV2

type ReCaptchaV2 struct {
	Type        string `json:"type"`
	WebsiteURL  string `json:"websiteURL"`
	WebsiteKey  string `json:"websiteKey"`
	IsInvisible bool   `json:"isInvisible,omitempty"`
	Sa          string `json:"sa,omitempty"`
	S           string `json:"s,omitempty"`
}

type ReCaptchaV3

type ReCaptchaV3 struct {
	Type        string `json:"type"`
	WebsiteURL  string `json:"websiteURL"`
	WebsiteKey  string `json:"websiteKey"`
	IsInvisible bool   `json:"isInvisible,omitempty"`
	PageAction  string `json:"pageAction,omitempty"`
}

type SolutionRequest

type SolutionRequest struct {
	ClientKey string `json:"clientKey"`
	TaskID    string `json:"taskId"`
}

type SolutionResponse

type SolutionResponse struct {
	ErrorID          int `json:"errorId"`
	ErrorCode        any `json:"errorCode,omitempty"`
	ErrorDescription any `json:"errorDescription,omitempty"`
	Solution         struct {
		GRecaptchaResponse string `json:"gRecaptchaResponse,omitempty"`
	} `json:"solution"`
	Status string `json:"status,omitempty"`
}

type TaskRequest

type TaskRequest struct {
	Client
	Task any `json:"task"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL