package Netease import ( "encoding/json" "gitea.ddegame.cn/open/servicebase/pkg/log" "github.com/pkg/errors" "github.com/spf13/viper" captcha "github.com/yidun/yidun-golang-sdk/yidun/service/captcha" ) // CaptchaSecondVerify 验证码二次校验请求 func CaptchaSecondVerify(captchaId, validate string) (bool, error) { request := captcha.NewCaptchaVerifyRequest() var user string = "" request.SetCaptchaId(captchaId).SetValidate(validate).SetUser(user) secretId := viper.GetString("netease.captcha.secretId") secretKey := viper.GetString("netease.captcha.secretKey") captchaClient := captcha.NewCaptchaVerifyClientWithAccessKey(secretId, secretKey) response, err := captchaClient.Verify(request) if err != nil { log.ErrorF("CaptchaSecondVerify err: %+v", err) return false, err } if response == nil { log.ErrorF("CaptchaSecondVerify response is nil") return false, errors.Errorf("CaptchaSecondVerify response is nil") } respBody, err := json.Marshal(response) if err != nil { return false, err } log.InfoF("CaptchaSecondVerify response is : %s", string(respBody)) if response.Result == nil { log.ErrorF("CaptchaSecondVerify response.Result is nil") return false, errors.Errorf("CaptchaSecondVerify response.Result is nil") } return *response.Result, nil }