Region
: region information in the domain name. This parameter determines the access point. For example, ocr.ap-shanghai.tencentcloudapi.com
means Shanghai is the access point. The common parameter Region
determines where business resources to be accessed reside. For example, Region=ap-beijing
means resources in the Beijing region will be accessed. If no region is specified in the domain name, a nearby region will be accessed by default. But if the IP address fails to be resolved, Guangdong region will be accessed by default. You can configure different regions for domain name and common parameter, but this may cause latency. Thus, we recommend selecting the same Region
, such as ap-guangzhou for South China (Guangzhou).const tencentcloud = require("../../../../tencentcloud-sdk-nodejs");const OcrClient = tencentcloud.ocr.v20181119.Client;const models = tencentcloud.ocr.v20181119.Models;const Credential = tencentcloud.common.Credential;const ClientProfile = tencentcloud.common.ClientProfile;const HttpProfile = tencentcloud.common.HttpProfile;Credential cred = new Credential("secretId", "secretKey");let httpProfile = new HttpProfile();let clientProfile = new ClientProfile();/*We recommend using V3 authentication, which is required if the request size exceeds 1 MB. Except for Node.js, SDKs in all other languages support V3.clientProfile.signMethod = "TC3-HMAC-SHA256";*/clientProfile.httpProfile = httpProfile;let client = new OcrClient(cred, "ap-guangzhou", clientProfile);let req = new models.IDCardOCRRequest();req.ImageUrl = "[https://test.jpg](https://test.jpg/)";req.CardSide = "FRONT";let config = {"CropPortrait":true};req.Config = JSON.stringify(config)client.IDCardOCR(req, function(errMsg, response) {if (errMsg) {console.log(error);return;}console.log(response.to_json_string());});
Region
field for common parameters. We recommend using “ap-guangzhou” for both the domain name and Region
.data:image/jpg;base64,
prefix and the line break \\n
.[TencentCloudSDKException]message:AuthFailure.SignatureFailure-The provided credentialscould not be validated because of exceeding request size limit, please use new signaturemethod `TC3-HMAC-SHA256`. requestId:719970d4-5814-4dd9-9757-a3f11ecc9b20
clientProfile.setSignMethod("TC3-HMAC-SHA256"); // Specifies the signature algorithm, which is HmacSHA256 by default
Was this page helpful?