








https://www.tencentcloud.com/products/faceid. After the verification process completed, the redirect address will be spliced to BizToken of the current process in the format as follows: https://www.tencentcloud.com/products/faceid? token={BizToken}.import com.tencentcloudapi.common.Credential;import com.tencentcloudapi.common.profile.ClientProfile;import com.tencentcloudapi.common.profile.HttpProfile;import com.tencentcloudapi.common.exception.TencentCloudSDKException;import com.tencentcloudapi.faceid.v20180301.FaceidClient;import com.tencentcloudapi.faceid.v20180301.models.*;;public class ApplyWebVerificationBizTokenIntl{public static void main(String [] args) {try{// Instantiate an authentication object. The secretId and secretKey of Tencent Cloud account shall be passed in. Note: keep the key pair confidential here.// Obtain the key at https://console.tencentcloud.com/cam/capiCredential cred = new Credential("TENCENTCLOUD_SECRET_ID","TENCENTCLOUD_SECRET_KEY");// Instantiate an http option, optional. Skip this if there are no special requirements.HttpProfile httpProfile = new HttpProfile();httpProfile.setEndpoint("faceid.tencentcloudapi.com");// Instantiate a client option, optional. Skip this if there are no special requirements.ClientProfile clientProfile = new ClientProfile();clientProfile.setHttpProfile(httpProfile);// Instantiate the client object of the product to be requested. The clientProfile is optional.FaceidClient client = new FaceidClient(cred, "ap-singapore", clientProfile);// Instantiate a request object, one for each interface.ApplyWebVerificationBizTokenIntlRequest req = new ApplyWebVerificationBizTokenIntlRequest();req.setRedirectURL("https://www.tencentcloud.com/products/faceid");WebVerificationConfigIntl webVerificationConfigIntl = new WebVerificationConfigIntl();webVerificationConfigIntl.setCheckMode(1L);webVerificationConfigIntl.setIDCardType("HKIDCard");req.setConfig(webVerificationConfigIntl);// The “resp” returned is an instance of ApplyWebVerificationBizTokenIntlResponse, corresponding to the request object.ApplyWebVerificationBizTokenIntlResponse resp = client.ApplyWebVerificationBizTokenIntl(req);// The string response package output in json format.System.out.println(ApplyWebVerificationBizTokenIntlResponse.toJsonString(resp));String bizToken = resp.getBizToken();String verificationURL = resp.getVerificationURL();System.out.printf("BizToken: %s, VerificationURL: %s", bizToken, verificationURL);} catch (TencentCloudSDKException e) {System.out.println(e.toString());}}}
import com.tencentcloudapi.common.Credential;import com.tencentcloudapi.common.profile.ClientProfile;import com.tencentcloudapi.common.profile.HttpProfile;import com.tencentcloudapi.common.exception.TencentCloudSDKException;import com.tencentcloudapi.faceid.v20180301.FaceidClient;import com.tencentcloudapi.faceid.v20180301.models.*;import java.util.Arrays;public class GetWebVerificationResultIntl {public static void main(String [] args) {try{// Instantiate an authentication object. The secretId and secretKey of Tencent Cloud account shall be passed in. Note: keep the key pair confidential here.// Obtain the key at https://console.tencentcloud.com/cam/capiCredential cred = new Credential("TENCENTCLOUD_SECRET_ID","TENCENTCLOUD_SECRET_KEY");// Instantiate an http option, optional. Skip this if there are no special requirements.HttpProfile httpProfile = new HttpProfile();httpProfile.setEndpoint("faceid.tencentcloudapi.com");// Instantiate a client option, optional. Skip this if there are no special requirements.ClientProfile clientProfile = new ClientProfile();clientProfile.setHttpProfile(httpProfile);// Instantiate the client object of the product to be requested. The clientProfile is optional.FaceidClient client = new FaceidClient(cred, "ap-singapore", clientProfile);// Instantiate a request object, one for each interface.GetWebVerificationResultIntlRequest req = new GetWebVerificationResultIntlRequest();req.setBizToken("xxx"); // Enter the BizToken returned from ApplyWebVerificationBizTokenIntl phase.// The “resp” returned is an instance of GetWebVerificationResultIntlResponse, corresponding to the requested object.GetWebVerificationResultIntlResponse resp = client.GetWebVerificationResultIntl(req);// The string response package output in json format.System.out.println(GetWebVerificationResultIntlResponse.toJsonString(resp));Long errorCode = resp.getErrorCode();String errorMsg = resp.getErrorMsg();// For details of the “OCRResult” field, please refer to OCRResult related documents at https://www.tencentcloud.com/document/api/1061/49423#ocr result.OCRResult[] ocrResult = resp.getOCRResult();if (errorCode == 0) {// Verification passed.System.out.println("Success");System.out.printf("OCRResult:%s", Arrays.toString(ocrResult));}else {// Verification failed.System.out.printf("Fail: %s\\n", errorMsg);}} catch (TencentCloudSDKException e) {System.out.println(e.toString());}}}
// Obtain VerificationURL from server.const VerificationURL = 'https://sg.faceid.qq.com/reflect/? token=*****';// Redirect from frontend page.window.location.href = VerificationURL;
// Obtain RedirectURLconst RedirectURL = "https://*****? token={BizToken}";// Parse to obtain BizToken parameter of RedirectURL, which is used to pull result information of this liveness comparison.const bizToken = getURLParameter(RedirectURL, "token");if (bizToken) {// Use bizToken to pull result information of this liveness comparison.}/**/ * Parse url parameters/* @params url To query url/* @params variable To query parameters*/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