Java SDK官方文档

将Java SDK加入本地的maven仓库

  1. sdk
  2. └── lib
  3. ├── ag-sdk-biz-74152.tar.gz-20211108.111327-SNAPSHOT.jar
  4. ├── ag-sdk-biz-74152.tar.gz-20211108.111327-SNAPSHOT.pom.xml
  5. ├── ctg-ag-sdk-core-2.5.0-20211018.013334-41.jar
  6. └── ctg-ag-sdk-core-2.5.0-20211018.013334-41.pom.xml

ag-sdk依赖于ctg-ag-sdk-core,所以要先安装ctg-ag-sdk

  1. mvn install:install-file -Dfile=ctg-ag-sdk-core-2.5.0-20211018.013334-41.jar -DpomFile=ctg-ag-sdk-core-2.5.0-20211018.013334-41.pom.xml
  2. mvn org.apache.maven.plugins:maven-install-plugin:2.5.1:install-file -Dfile=ag-sdk-biz-74152.tar.gz-20211108.111327-SNAPSHOT.jar -DpomFile=ag-sdk-biz-ag-sdk-biz-74152.tar.gz-20211108.111327-SNAPSHOT.pom.xml

在工程中引用包

在pom文件中加入

  1. <groupId>com.ctg.ag</groupId>
  2. <artifactId>ctg-ag-sdk-core</artifactId>
  3. <version>2.5.0-SNAPSHOT</version>
  4. <groupId>com.ctg.ag</groupId>
  5. <artifactId>ag-sdk-biz-44137.tar.gz</artifactId>
  6. <version>20201027.162343-SNAPSHOT</version>

注:以上坐标供参考,具体以“lib”目录下的两个pom文件为准。

测试SDK

参考demo目录下的java调用示例

以数据签名为例,appKey即您的App Key,appSecret为对应的App Secret,Appkey和AppSecret的获取请查看相关应用的详情界面。对于具体的请求参数,可以参考doc目录下的md文件。

  1. public void testApiWithSignature() throws Exception {
  2. AepDeviceCommandClient client = AepDeviceCommandClient.newClient().appKey("Your app key here").appSecret("Your app secret here").build();
  3. {
  4. QueryCommandListRequest request = new QueryCommandListRequest();
  5. // request.setParam.. // set your request params here
  6. request.setParamMasterKey("MasterKey");
  7. request.setParamProductId("ProductId");
  8. request.setParamDeviceId("DeviceId");
  9. System.out.println(client.QueryCommandList(request));
  10. }
  11. client.shutdown();
  12. }