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.tms.v20201229.TmsClient;
import com.tencentcloudapi.tms.v20201229.models.*;
public class TextModeration {
public static void main(String[] args) {
try {
// Instantiate an authentication object. Pass in `secretId` and `secretKey` of your Tencent Cloud account as the input parameters and keep them confidential
// You can get them by visiting https://console.tencentcloud.com/cam/capi
Credential cred = new Credential("SecretId", "SecretKey");
// (Optional) Instantiate an HTTP option
HttpProfile httpProfile = new HttpProfile();
httpProfile.setEndpoint("tms.tencentcloudapi.com");
// Instantiate a client option (optional; skip if no special requirements are present)
ClientProfile clientProfile = new ClientProfile();
clientProfile.setHttpProfile(httpProfile);
// Instantiate the client object of the requested product. `clientProfile` is optional
TmsClient client = new TmsClient(cred, "ap-guangzhou", clientProfile);
// Instantiate a request object. Each API corresponds to a request object
TextModerationRequest req = new TextModerationRequest();
// The returned `resp` is an instance of `TextModerationResponse` which corresponds to the request object
TextModerationResponse resp = client.TextModeration(req);
// A string return packet in JSON format is output
System.out.println(TextModerationResponse.toJsonString(resp));
} catch (TencentCloudSDKException e) {
System.out.println(e.toString());
}
}
}
Was this page helpful?