

Method | Description | Advantages | Disadvantage | Scenarios |
Method A: Using Config Parameters | Pass all configurations via the Config parameter when the API is called. | Flexible, no pre-configuration required | Full parameters must be passed in for each call. | Configurations change frequently, or dynamic control of the process is required. |
Method B: Using RuleId | Pre-configure the process in the console, and pass only the RuleId when calling. | Simplifies invocation and centralizes management | Pre-configuration required, and approval takes one business day. | Fixed configurations, with multiple applications sharing the same process. |







https://www.tencentcloud.com/products/faceid. After the verification process is completed, the BizToken for that session is appended to the callback address, and the redirection is performed in the format 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. Input parameters need to include secretId and secretKey of the Tencent Cloud account. Keep the confidentiality of the key pair.// The key can be obtained at https://console.tencentcloud.com/cam/capi.Credential cred = new Credential("TENCENTCLOUD_SECRET_ID","TENCENTCLOUD_SECRET_KEY");// Instantiate an HTTP option (optional). Skip it if there are no special requirements.HttpProfile httpProfile = new HttpProfile();httpProfile.setEndpoint("faceid.intl.tencentcloudapi.com");// Instantiate a client option (optional). Skip it if there are no special requirements.ClientProfile clientProfile = new ClientProfile();clientProfile.setHttpProfile(httpProfile);// Instantiate the client object that requests the product. clientProfile is optional.FaceidClient client = new FaceidClient(cred, "ap-singapore", clientProfile);// Instantiate a request object. Each API will correspond to a request object.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 returned `resp` is an instance of `ApplyWebVerificationBizTokenIntlResponse`, which corresponds to the request object.ApplyWebVerificationBizTokenIntlResponse resp = client.ApplyWebVerificationBizTokenIntl(req);// Output a string packet 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. Input parameters need to include secretId and secretKey of the Tencent Cloud account. Keep the confidentiality of the key pair.// The key can be obtained at https://console.tencentcloud.com/cam/capi.Credential cred = new Credential("TENCENTCLOUD_SECRET_ID","TENCENTCLOUD_SECRET_KEY");// Instantiate an HTTP option (optional). Skip it if there are no special requirements.HttpProfile httpProfile = new HttpProfile();httpProfile.setEndpoint("faceid.intl.tencentcloudapi.com");// Instantiate a client option (optional). Skip it if there are no special requirements.ClientProfile clientProfile = new ClientProfile();clientProfile.setHttpProfile(httpProfile);// Instantiate the client object that requests the product. clientProfile is optional.FaceidClient client = new FaceidClient(cred, "ap-singapore", clientProfile);// Instantiate a request object. Each API will correspond to a request object.GetWebVerificationResultIntlRequest req = new GetWebVerificationResultIntlRequest();req.setBizToken("xxx"); // Enter the BizToken returned by the ApplyWebVerificationBizTokenIntl stage.// The returned `resp` is an instance of `GetWebVerificationResultIntlResponse`, which corresponds to the request object.GetWebVerificationResultIntlResponse resp = client.GetWebVerificationResultIntl(req);// Output a string packet in JSON format.System.out.println(GetWebVerificationResultIntlResponse.toJsonString(resp));Long errorCode = resp.getErrorCode();String errorMsg = resp.getErrorMsg();// For details about the OCRResult fields, see the OCRResult documentation.// https://www.tencentcloud.com/document/api/1061/49423#ocrresultOCRResult[] ocrResult = resp.getOCRResult();if (errorCode == 0) {// Verification passedSystem.out.println("Success");System.out.printf("OCRResult:%s", Arrays.toString(ocrResult));} else {// Verification failedSystem.out.printf("Fail: %s\\n", errorMsg);}} catch (TencentCloudSDKException e) {System.out.println(e.toString());}}}
// Obtain the VerificationURL from the serverconst VerificationURL = 'https://sg.faceid.qq.com/reflect/?token=*****';// Frontend page redirectwindow.location.href = VerificationURL;
// Obtain the RedirectURLconst RedirectURL = "https://*****?token={BizToken}";// Parse the BizToken parameter from the RedirectURL to retrieve the result information of this liveness comparison.const bizToken = getURLParameter(RedirectURL, "token");if (bizToken) {// Use the bizToken to retrieve the result information of this liveness comparison.}/**// Parse the url parameters* @param {string} url The query url* @param {string} variable The query parameter* @returns {string|false}*/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;}
Apakah halaman ini membantu?
Anda juga dapat Menghubungi Penjualan atau Mengirimkan Tiket untuk meminta bantuan.
masukan