File tree Expand file tree Collapse file tree 1 file changed +9
-0
lines changed
Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change 77 "net/http"
88)
99
10+ // arcaptchaApi arcaptcha verify API for captcha V2
1011const arcaptchaApi = "https://arcaptcha.ir/2/siteverify"
1112
1213type Website struct {
@@ -20,18 +21,25 @@ type verifyReq struct {
2021 ChallengeID string `json:"challenge_id"`
2122}
2223
24+ // VerifyResp represents verify API response
25+ // error codes are available in https://docs.arcaptcha.ir/en/API/Verify
2326type VerifyResp struct {
2427 Success bool `json:"success"`
2528 ErrorCodes []string `json:"error-codes"`
2629}
2730
31+ // NewWebsite creates a new Website
2832func NewWebsite (siteKey , secretKey string ) * Website {
2933 return & Website {
3034 SiteKey : siteKey ,
3135 SecretKey : secretKey ,
3236 }
3337}
3438
39+ // Verify calls arcaptcha verify API and returns result.
40+ //
41+ // if an error occurs while sending or receiving the request, returns error.
42+ // server side errors are available in VerifyResp.ErrorCodes.
3543func (w * Website ) Verify (token string ) (VerifyResp , error ) {
3644 data := & verifyReq {
3745 SiteKey : w .SiteKey ,
@@ -43,6 +51,7 @@ func (w *Website) Verify(token string) (VerifyResp, error) {
4351 return resp , err
4452}
4553
54+ // sendRequest sends http request to 'url' and fill 'resp' by response body
4655func sendRequest (method , url string , data interface {}, resp interface {}) error {
4756 bin , err := json .Marshal (data )
4857 if err != nil {
You can’t perform that action at this time.
0 commit comments