

RedirectURL should include the protocol, hostname, and path. An example value is https://www.tencentcloud.com/products/faceid. After the verification process is completed, the BizToken of this process will be added to the callback URL in the format of https://www.tencentcloud.com/products/faceid?token={BizToken} before redirect.GetWebVerificationResultIntl.Config is as follows:RedirectURL. The default value is false.package mainimport ("fmt""os""github.com/tencentcloud/tencentcloud-sdk-go-intl-en/tencentcloud/common""github.com/tencentcloud/tencentcloud-sdk-go-intl-en/tencentcloud/common/profile""github.com/tencentcloud/tencentcloud-sdk-go-intl-en/tencentcloud/common/regions"faceid "github.com/tencentcloud/tencentcloud-sdk-go-intl-en/tencentcloud/faceid/v20180301""github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/errors")func ApplyWebVerificationBizTokenIntl(imageBase64 string) {// Set TencentCloud API access keycredential := common.NewCredential(os.Getenv("TENCENTCLOUD_SECRET_ID"),os.Getenv("TENCENTCLOUD_SECRET_KEY"),)cpf := profile.NewClientProfile()client, _ := faceid.NewClient(credential, regions.Singapore, cpf)request := faceid.NewApplyWebVerificationBizTokenIntlRequest()request.RedirectURL = common.StringPtr("https://www.tencentcloud.com/products/faceid")// Pass in CompareImageBase64 and Extrarequest.CompareImageBase64 = common.StringPtr(imageBase64)request.Extra = common.StringPtr("ExtraString")response, err := client.ApplyWebVerificationBizTokenIntl(request)if _, ok := err.(*errors.TencentCloudSDKError); ok {fmt.Printf("An API error has returned: %s", err)return}if err != nil {panic(err)}// Obtain BizToken and VerificationURLbizToken := *response.Response.BizTokenverificationURL := *response.Response.VerificationURLfmt.Printf("BizToken: %s, VerificationURL: %s", bizToken, verificationURL)}
ErrorCode in the response is 0, it indicates that the verification is successful. In other cases, verification failed. For other error codes, see Selfie Verification (Mobile HTML5) Error Codes.ApplyWebVerificationBizTokenIntl API, which is a unique identifier for the current verification process.package mainimport ("fmt""os""github.com/tencentcloud/tencentcloud-sdk-go-intl-en/tencentcloud/common""github.com/tencentcloud/tencentcloud-sdk-go-intl-en/tencentcloud/common/profile""github.com/tencentcloud/tencentcloud-sdk-go-intl-en/tencentcloud/common/regions"faceid "github.com/tencentcloud/tencentcloud-sdk-go-intl-en/tencentcloud/faceid/v20180301""github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/errors")func GetWebVerificationResult(bizToken string) {// Set TencentCloud API access keycredential := common.NewCredential(os.Getenv("TENCENTCLOUD_SECRET_ID"),os.Getenv("TENCENTCLOUD_SECRET_KEY"),)cpf := profile.NewClientProfile()client, _ := faceid.NewClient(credential, regions.Singapore, cpf)request := faceid.NewGetWebVerificationResultIntlRequest()// Pass in BizTokenrequest.BizToken = common.StringPtr(bizToken)response, err := client.GetWebVerificationResultIntl(request)if _, ok := err.(*errors.TencentCloudSDKError); ok {fmt.Printf("An API error has returned: %s", err)return}if err != nil {panic(err)}if response.Response.ErrorCode == nil {fmt.Print("the verification is uncompleted.")return}errorCode := *response.Response.ErrorCodeerrorMsg := *response.Response.ErrorMsgif errorCode == 0 {// Verification succeededfmt.Print("Success")}else{// Verification failedfmt.Printf("Fail: %s\\n", errorMsg)}}
// Obtain VerificationURL from the serverconst VerificationURL = 'https://sg.faceid.qq.com/reflect/?token=*****';// Redirect the frontend pagewindow.location.href = VerificationURL;
RedirectURL. The BizToken parameter for the current process is added to the RedirectURL. By parsing the RedirectURL, you can obtain the BizToken parameter, which is used to obtain the verification result. This corresponds to step 12 in the interaction process.// Obtain RedirectURLconst RedirectURL = "https://*?token={BizToken}";// Parse RedirectURL to obtain the BizToken parameter, which is used to obtain the verification resultconst bizToken = getURLParameter(RedirectURL, "token");if (bizToken) {// Use bizToken to obtain the verification result}/**/ * Get URL parameters/* @params url The URL to be queried/* @params variable The parameter to be queried*/function getURLParameter(url, variable) {const query = url.split('?')[1] || '';const vars = query.split('&');for (let i = 0; i < vars.length; i++) {const pair = vars[i].split('=');if (pair[0] == variable) {return pair[1];}}return (false);}
Feedback