全部产品
云市场

SDK

更新时间:2019-09-10 13:34:57

简介

  通过使用阿里云风险识别SDK,调用方不需要再关注签名验证以及 Body 格式构建等繁琐的事情,推荐使用。

SDK下载

一、JAVA SDK

JAVA SDK 源码下载:https://github.com/aliyun/aliyun-openapi-java-sdk/tree/master/aliyun-java-sdk-saf

JAVA SDK 的环境准备、安装使用可参考: 阿里云SDK开发指南

JAVA Maven依赖:

  1. <dependency>
  2. <groupId>com.aliyun</groupId>
  3. <artifactId>aliyun-java-sdk-saf</artifactId>
  4. <version>1.0.2</version>
  5. </dependency>

JAVA Maven推荐依赖仲裁:

  1. <dependency>
  2. <groupId>com.aliyun</groupId>
  3. <artifactId>aliyun-java-sdk-core</artifactId>
  4. <optional>true</optional>
  5. <version>4.1.1</version>
  6. </dependency>
  7. <dependency>
  8. <groupId>com.alibaba</groupId>
  9. <artifactId>fastjson</artifactId>
  10. <version>1.2.60</version>
  11. </dependency>
  12. <dependency>
  13. <groupId>com.google.code.gson</groupId>
  14. <artifactId>gson</artifactId>
  15. <version>2.8.2</version>
  16. </dependency>

JAVA用例:https://github.com/aliyun/aliyun-openapi-java-sdk/blob/master/aliyun-java-sdk-saf/src/test/java/SafPopTest.java

JAVA Maven仓库:https://oss.sonatype.org/#nexus-search;quick~aliyun-java-sdk-saf

二、Python SDK

Python SDK 源码下载:https://github.com/aliyun/aliyun-openapi-python-sdk/tree/master/aliyun-python-sdk-saf

Python SDK的环境准备、安装使用可参考:阿里云SDK开发指南

  1. 安装SDK核心库。
    • 如果您使用Python 2.x,执行以下命令,安装阿里云SDK核心库:
      1. pip install aliyun-python-sdk-core
    • 如果您使用Python 3.x,执行以下命令,安装阿里云SDK核心库:
      1. pip install aliyun-python-sdk-core-v3
  2. 安装云产品SAF SDK。
    1. pip install aliyun-python-sdk-saf

Python用例:

  1. from aliyunsdkcore import client
  2. from aliyunsdksaf.request.v20180919 import ExecuteRequestRequest
  3. clt = client.AcsClient('<your-access-key-id>','<your-access-key-secret>','cn-shanghai')
  4. # 设置参数
  5. request = ExecuteRequestRequest.ExecuteRequestRequest()
  6. request.set_accept_format('json')
  7. request.add_query_param('Service', '购买的产品service')
  8. request.add_query_param('ServiceParameters', 'json串')
  9. # 发起请求
  10. response = clt.do_action_with_exception(request)
  11. print(response)

三、PHP SDK

PHP SDK 源码下载:https://github.com/aliyun/aliyun-openapi-php-sdk/tree/master/aliyun-php-sdk-saf

PHP SDK的环境准备、安装使用可参考:阿里云SDK开发指南

PHP用例:

  1. <?php
  2. include_once 'aliyun-openapi-php-sdk/aliyun-php-sdk-core/Config.php';
  3. use saf\Request\V20180919 as saf;
  4. // 初始化
  5. $iClientProfile = DefaultProfile::getProfile("cn-shanghai", "<your-access-key-id>", "<your-access-key-secret>");
  6. $client = new DefaultAcsClient($iClientProfile);
  7. //设置参数
  8. $request = new saf\ExecuteRequestRequest();
  9. $request->setService('购买的产品service');
  10. $request->setServiceParameters('json串');
  11. // 发起请求
  12. $response = $client->getAcsResponse($request);
  13. print_r("<br>");
  14. print_r("test");
  15. print_r("\r\n");
  16. print_r($response);
  17. print_r($client);
  18. ?>

四、C# SDK

C# SDK源码下载:https://github.com/aliyun/aliyun-openapi-net-sdk/tree/master/aliyun-net-sdk-saf

C# SDK的环境准备、安装使用可参考:阿里云SDK开发指南

五、Golang SDK

Golang SDK源码下载:https://github.com/aliyun/alibaba-cloud-sdk-go/tree/master/services/saf

Golang SDK的环境准备、安装使用可参考:阿里云SDK开发指南

Golang用例:

  1. package main
  2. import (
  3. "fmt"
  4. "github.com/aliyun/alibaba-cloud-sdk-go/services/saf"
  5. )
  6. func main() {
  7. client, err := saf.NewClientWithAccessKey("cn-shanghai", "<your-access-key-id>", "<your-access-key-secret>")
  8. request := saf.CreateExecuteRequestRequest()
  9. // 产品service请参考[公共参数]文档中的Service字段描述
  10. request.Service = "购买的产品service"
  11. request.ServiceParameters = "json串"
  12. request.Scheme = "https"
  13. response, err := client.ExecuteRequest(request)
  14. if err != nil {
  15. fmt.Print(err.Error())
  16. }
  17. fmt.Printf("response code is %#v\n", response.Code)
  18. fmt.Printf("response date is %#v\n", response.Data)
  19. fmt.Printf("response message is %#v\n", response.Message)
  20. fmt.Printf("response requestId is %#v\n", response.RequestId)
  21. }