产品动态
产品公告









https://www.tencentcloud.com/products/faceid。核验流程完成后,回调地址会拼接当次流程的 BizToken,以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{// 实例化一个认证对象,入参需要传入腾讯云账户secretId,secretKey,此处还需注意密钥对的保密// 密钥可前往https://console.tencentcloud.com/cam/capi网站进行获取Credential cred = new Credential("TENCENTCLOUD_SECRET_ID","TENCENTCLOUD_SECRET_KEY");// 实例化一个http选项,可选的,没有特殊需求可以跳过HttpProfile httpProfile = new HttpProfile();httpProfile.setEndpoint("faceid.tencentcloudapi.com");// 实例化一个client选项,可选的,没有特殊需求可以跳过ClientProfile clientProfile = new ClientProfile();clientProfile.setHttpProfile(httpProfile);// 实例化要请求产品的client对象,clientProfile是可选的FaceidClient client = new FaceidClient(cred, "ap-singapore", clientProfile);// 实例化一个请求对象,每个接口都会对应一个request对象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);// 返回的resp是一个ApplyWebVerificationBizTokenIntlResponse的实例,与请求对象对应ApplyWebVerificationBizTokenIntlResponse resp = client.ApplyWebVerificationBizTokenIntl(req);// 输出json格式的字符串回包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{// 实例化一个认证对象,入参需要传入腾讯云账户secretId,secretKey,此处还需注意密钥对的保密// 密钥可前往https://console.tencentcloud.com/cam/capi网站进行获取Credential cred = new Credential("TENCENTCLOUD_SECRET_ID","TENCENTCLOUD_SECRET_KEY");// 实例化一个http选项,可选的,没有特殊需求可以跳过HttpProfile httpProfile = new HttpProfile();httpProfile.setEndpoint("faceid.tencentcloudapi.com");// 实例化一个client选项,可选的,没有特殊需求可以跳过ClientProfile clientProfile = new ClientProfile();clientProfile.setHttpProfile(httpProfile);// 实例化要请求产品的client对象,clientProfile是可选的FaceidClient client = new FaceidClient(cred, "ap-singapore", clientProfile);// 实例化一个请求对象,每个接口都会对应一个request对象GetWebVerificationResultIntlRequest req = new GetWebVerificationResultIntlRequest();req.setBizToken("xxx"); //输入ApplyWebVerificationBizTokenIntl阶段返回的BizToken// 返回的resp是一个GetWebVerificationResultIntlResponse的实例,与请求对象对应GetWebVerificationResultIntlResponse resp = client.GetWebVerificationResultIntl(req);// 输出json格式的字符串回包System.out.println(GetWebVerificationResultIntlResponse.toJsonString(resp));Long errorCode = resp.getErrorCode();String errorMsg = resp.getErrorMsg();//详细 OCRResult 字段,请参考OCRResult相关文档https://www.tencentcloud.com/document/api/1061/49423#ocrresult。OCRResult[] ocrResult = resp.getOCRResult();if (errorCode == 0) {// 核验通过System.out.println("Success");System.out.printf("OCRResult:%s", Arrays.toString(ocrResult));}else {// 核验不通过System.out.printf("Fail: %s\\n", errorMsg);}} catch (TencentCloudSDKException e) {System.out.println(e.toString());}}}
// 从服务端获取VerificationURLconst VerificationURL = 'https://sg.faceid.qq.com/reflect/?token=*****';// 前端页面跳转window.location.href = VerificationURL;
// 获取RedirectURLconst RedirectURL = "https://*****?token={BizToken}";// 解析获得RedirectURL的BizToken参数,用于拉取本次活体比对的结果信息const bizToken = getURLParameter(RedirectURL, "token");if (bizToken) {// 使用bizToken用于拉取本次活体比对的结果信息}/**/ * 解析url的参数/* @params url 查询url/* @params variable 查询参数*/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);}
文档反馈