Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrIllegalServer = errors.New("illegal server") ErrWrongUserID = errors.New("userid error") ErrEmptyID = errors.New("id empty") ErrWrongID = errors.New("id error") ErrWrongScene = errors.New("scene error") ErrWrongToken = errors.New("token error") ErrExpiredToken = errors.New("token expired") ErrOverrun = errors.New("frequency overrun") ErrBadRequest = errors.New("bad request") ErrIllegalParams = errors.New("params error") ErrUnknown = errors.New("unknown error") ErrInvalidResponse = errors.New("invalid response") )
Functions ¶
func RequestAndVerify ¶
func RequestAndVerify(request *CaptchaRequest) bool
RequestAndVerify will request and verify captcha info, return true if pass, otherwise false
Types ¶
type CaptchaRequest ¶
type CaptchaRequest struct { VID string `json:"id"` Key string `json:"secretkey"` Server string `json:"-"` Scene int `json:"scene"` Token string `json:"token"` ClientIP string `json:"ip"` UserID string `json:"userid,omitempty"` }
func (*CaptchaRequest) Request ¶
func (request *CaptchaRequest) Request() (*CaptchaResponse, error)
Request will send request to verify server and get response, if server is illegal, returns ErrIllegalServer,
type CaptchaResponse ¶
type CaptchaResponse struct { Success int `json:"success"` Score int `json:"score"` Msg string `json:"msg"` }
func (*CaptchaResponse) Verify ¶
func (response *CaptchaResponse) Verify() error
Verify will verify the response and return nil if pass, otherwise errors with details For example, ErrWrongUserID, ErrIllegalParams, etc. You can find these errors in defined variables.
Click to show internal directories.
Click to hide internal directories.