ims.tencentcloudapi.com
) or a specified region (at ims.ap-guangzhou.tencentcloudapi.com
for Guangzhou, for example).<dependencies>
tag in Maven's pom.xml
:<dependency><groupId>com.tencentcloudapi</groupId><artifactId>tencentcloud-sdk-java</artifactId><!-- go to https://search.maven.org/search?q=tencentcloud-sdk-java and get the latest version. --><!-- Query the latest version at https://search.maven.org/search?q=tencentcloud-sdk-java, which is as follows --><version>3.1.322</version></dependency>
artifactId
with tencentcloud-sdk-java-cvm/cbs/vpc
to import the SDK of the specific product. The code can be used in the same way, and the major packages are the same. For more information, see the samples.settings.xml
configuration file of Maven and add the mirror configuration in the mirrors
section:<mirror><id>tencent</id><name>tencent maven mirror</name><url>https://mirrors.tencent.com/nexus/repository/maven-public/</url><mirrorOf>*</mirrorOf></mirror>
vendor
directory in a path that can be found by Java.ImageModeration
API. The region
is configured as Guangzhou
as an example and should be configured as needed.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.ims.v20201229.ImsClient;import com.tencentcloudapi.ims.v20201229.models.*;public class ImageModeration{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/capiCredential cred = new Credential("SecretId", "SecretKey");// (Optional) Instantiate an HTTP optionHttpProfile httpProfile = new HttpProfile();httpProfile.setEndpoint("ims.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 optionalImsClient client = new ImsClient(cred, "ap-guangzhou", clientProfile);// Instantiate a request object. Each API corresponds to a request objectImageModerationRequest req = new ImageModerationRequest();// The returned `resp` is an instance of `ImageModerationResponse` which corresponds to the request objectImageModerationResponse resp = client.ImageModeration(req);// A string return packet in JSON format is outputSystem.out.println(ImageModerationResponse.toJsonString(resp));} catch (TencentCloudSDKException e) {System.out.println(e.toString());}}}
Was this page helpful?