Skip to main content

python sdk of taiqiyun

Project description

钛旗云 SDK 使用说明

Python 版(V1.0)

说明

该SDK需使用python3以上版本

安装 SDK

通过 pip 一键完成安装

pip install tisdk -U
使用 SDK 调试接口

安装完成后, 可直接在命令行使用 tireq 命令调试接口

tireq username secret_key method url [foo:bar,foo2:bar2...]

tireq 命令的参数依次是:

  1. 用户名 (由钛旗云系统分配)
  2. 密钥 (由钛旗云系统分配)
  3. 请求方法名 (get post put ...)
  4. 请求 url
  5. 请求体参数 (参数名和参数值以 : 相隔, 多对参数之间以 , 相隔) 非必须

参考示例如下

tireq myusername 4fbe6e7084ec4d05 post /api/xxx/v1 name1:value1
在代码中调用 SDK 发起请求

参考 Python 代码如下

import tisdk

username = 'myusername'
secret_key = '4fbe6e7084ec4d05'
method = 'post'
url = '/api/xxx/v1'
data = {'name1': 'value1'}

# 直接调用 ti_request 方法发起请求
# 每次发起请求时都传入`用户名`和`密钥`
tisdk.ti_request(username, secret_key, method, url, data)

# 以`用户名`和`密钥`初始化 Ti 对象
# 之后调用 Ti.request 方法发起请求, 不需每次传`用户名`和`密钥`
ti = tisdk.Ti(username, secret_key)
ti.request(method, url, data)

Java SDKV1.0下载

说明

通过我司提供的 jar 包工具类,可直接生成请求需要的签名和数据的加密或者直接发起请求

jar 包依赖第三方库 fastjson(1.2以上) 和 httpclient(4.5以上)

<dependency>
  <groupId>org.apache.httpcomponents</groupId>
  <artifactId>httpclient</artifactId>
  <version>4.5.9</version>
</dependency>
<dependency>
  <groupId>com.alibaba</groupId>
  <artifactId>fastjson</artifactId>
  <version>1.2.58</version>
</dependency>
jar 包工具类说明
  • AesUtils: Aes 加解密工具类
  • HmacSha256: Hmac256 生成工具类
  • RequestUtil: api 请求工具类
  • Ti: 钛旗云 sdk 工具类
在代码中调用 SDK 发起请求

参考 Java 代码如下

import com.alibaba.fastjson.JSON;
import com.kq300061.tisdk.AesUtils;
import com.kq300061.tisdk.Ti;

import java.util.HashMap;
import java.util.Map;

public class ReqTest {
    public static void main(String[] args) {
        try {
            String username = "username";
            String secret = "secret";
            String url = "https://XX//api/xxx/v1";
            HashMap<String, Object> reqbody = new HashMap<String, Object>() {{
                put("name", "abc");
                put("phone", "cdf");
                put("idCard", "123");
            }};

            // https
            String resp = new Ti(username, secret).doHttpsPost(url, reqbody);
            // 或者使用以下这种方式
            // Ti TiRequest = new Ti(username, secret);
            // String resp = TiRequest.doHttpsPost(url, reqbody);
            System.out.println(resp);

        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tisdk-0.1.2.tar.gz (10.0 kB view details)

Uploaded Source

File details

Details for the file tisdk-0.1.2.tar.gz.

File metadata

  • Download URL: tisdk-0.1.2.tar.gz
  • Upload date:
  • Size: 10.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.4.2 requests/2.23.0 setuptools/39.1.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.6.5

File hashes

Hashes for tisdk-0.1.2.tar.gz
Algorithm Hash digest
SHA256 569bdf11558504b59fab9d83bc4f7e280dba71b8a4375ec27e9eb6b0b0ec218c
MD5 10cc7fb2f7fb150d4cba8cd0f6b03ee2
BLAKE2b-256 eaff569f1587167facf28f3fa6c7a8fa3a092fae665838e90bba3731e180e8ea

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page