gt3

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ClientTypeWeb     = "web"     // web(pc浏览器)
	ClientTypeH5      = "h5"      // h5(手机浏览器,包括webview)
	ClientTypeNative  = "native"  // native(原生app)
	ClientTypeUnknown = "unknown" // unknown(未知)
)
View Source
const (
	// GeetestChallenge 极验二次验证表单传参字段 chllenge
	GeetestChallenge string = "geetest_challenge"
	// GeetestValidate 极验二次验证表单传参字段 validate
	GeetestValidate string = "geetest_validate"
	// GeetestSeccode 极验二次验证表单传参字段 seccode
	GeetestSeccode string = "geetest_seccode"
	// GeetestServerStatusSessionKey 极验验证API服务状态Session Key
	GeetestServerStatusSessionKey string = "gt_server_status"
)

Variables

View Source
var DefaultClientOptions = ClientOptions{
	APIURL:      "http://api.geetest.com",
	RegisterURL: "register.php",
	ValidteURL:  "validate.php",
	HTTPTimeout: 5,
	Version:     "golang-gin:3.1.0",
	ClientType:  ClientTypeUnknown,
	JSONFormat:  "1",
}

DefaultClientOptions 默认客户端配置

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client gt3客户端

func NewClient

func NewClient(geetestID string, geetestKey string, opts ...Option) *Client

NewClient 创建客户端

func (*Client) BuildChallenge

func (g *Client) BuildChallenge(challenge string, digestmod string) (enchallenge string)

BuildChallenge 构建验证初始化返回数据

func (*Client) Register

func (g *Client) Register(digestmod string, userID ...string) (res *RegisterResponse, err error)

Register register

func (*Client) Validate

func (g *Client) Validate(challenge, seccode string, userID ...string) (res *ValidateResponse, err error)

Validate validate

type ClientOptions

type ClientOptions struct {
	APIURL      string
	RegisterURL string
	ValidteURL  string
	HTTPTimeout int
	Version     string
	ClientType  string
	IPAddress   string
	JSONFormat  string
}

ClientOptions 客户端可选参数

type Option

type Option func(*ClientOptions)

Option 为可选参数赋值的函数

func OptionAPIURL

func OptionAPIURL(v string) Option

OptionAPIURL ...

func OptionRegisterURL

func OptionRegisterURL(v string) Option

OptionRegisterURL ...

type RegisterRequest

type RegisterRequest struct {
	*RequestComm
	Digestmod string `json:"digestmod"` // 生成唯一标识字符串的签名算法,默认暂支持md5
	Gt        string `json:"gt"`        // 向极验申请的账号id
}

RegisterRequest 请求参数

func (*RegisterRequest) Validation

func (req *RegisterRequest) Validation() (err error)

Validation 验证

type RegisterResponse

type RegisterResponse struct {
	Challenge string `json:"challenge"` // 生成唯一流水号的参考字符串,为”0”表示传参账号id有误
}

RegisterResponse 响应参数

type RegisterResponseForWeb

type RegisterResponseForWeb struct {
	Success    int    `json:"success"`     // 流程正常、异常标识;1表示正常,0表示异常、后续走宕机模式
	NewCaptcha string `json:"new_captcha"` // 新版验证码标识,固定不变
	Challenge  string `json:"challenge"`   // 流水号,一次完整验证流程的唯一标识
	Gt         string `json:"gt"`          // 向极验申请的账号id
}

RegisterResponseForWeb register response for web

type RequestComm

type RequestComm struct {
	UserID     string `json:"user_id"`     // user_id作为终端用户的唯一标识,确定用户的唯一性;作用于提供进阶数据分析服务,可在api1 或 api2 接口传入,不传入也不影响验证服务的使用;若担心用户信息风险,可作预处理(如哈希处理)再提供到极验
	ClientType string `json:"client_type"` // 客户端类型,web(pc浏览器),h5(手机浏览器,包括webview),native(原生app),unknown(未知)
	IPAddress  string `json:"ip_address"`  // 客户端请求SDK服务器的ip地址
	JSONFormat string `json:"json_format"` // json格式化标识
	Sdk        string `json:"sdk"`         // sdk代码版本号
}

RequestComm 通用请求参数

func (*RequestComm) Validation

func (req *RequestComm) Validation() (err error)

Validation 验证

type ValidateRequest

type ValidateRequest struct {
	*RequestComm
	Seccode   string `json:"seccode"`   // 核心校验数据
	Challenge string `json:"challenge"` // 流水号,一次完整验证流程的唯一标识
	CaptchaID string `json:"captchaid"` // 向极验申请的账号id
}

ValidateRequest 请求参数

func (*ValidateRequest) Validation

func (req *ValidateRequest) Validation() (err error)

Validation 验证

type ValidateResponse

type ValidateResponse struct {
	Seccode string `json:"seccode"` // 验证结果标识,为”false”表示验证不通过
}

ValidateResponse 响应参数

Jump to

Keyboard shortcuts

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