开发者社区> 问答> 正文

阿里云通用SDK如何调用?

阿里云通用SDK如何调用?

展开
收起
保持可爱mmm 2020-04-06 00:58:51 784 0
1 条回答
写回答
取消 提交回答
  • 阿里云通用SDK调用:

    <dependency>
       <groupId>com.aliyun</groupId>
       <artifactId>aliyun-java-sdk-core</artifactId>
       <version>4.3.4</version>
    </dependency>
    

    调用示例

    public static void main(String[] args) throws Exception {
       String accountAccessAK = "XXXXXXXXXXXXXXXXXX";
       String accountAccessSK = "XXXXXXXXXXXXXXXXXX";
       String popRegion = "cn-shanghai";
       String popProduct = "Chatbot";
       String popDomain = "chatbot.cn-shanghai.aliyuncs.com";
       DefaultProfile.addEndpoint(popRegion, popProduct, popDomain);
       IClientProfile profile = DefaultProfile.getProfile(popRegion, accountAccessAK, accountAccessSK);
       DefaultAcsClient client = new DefaultAcsClient(profile);
       //固定入参
       CommonRequest commonRequest = new CommonRequest();
       commonRequest.setSysProduct("Chatbot");
       commonRequest.setSysMethod(MethodType.GET);
       //根据API会有变化
       commonRequest.setSysAction("Chat");
       commonRequest.setSysVersion("2017-10-11");
       commonRequest.putQueryParameter("Utterance", "hi");
       //机器人id
       commonRequest.putQueryParameter("InstanceId", "chatbot-cn-xxxxxxxxxxxx");
       CommonResponse commonResponse = client.getCommonResponse(commonRequest);
       System.out.println(commonResponse.getData());
    }
    
    2020-04-06 00:59:38
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
从 SDK 到编解码:视频直播架构解析 立即下载
跨平台的云服务SDK需要什么 立即下载
一个跨平台的云服务SDK需要什么 立即下载