钛旗云 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 命令的参数依次是:
- 用户名 (由钛旗云系统分配)
- 密钥 (由钛旗云系统分配)
- 请求方法名 (
getpostput...) - 请求 url
- 请求体参数 (参数名和参数值以
:相隔, 多对参数之间以,相隔) 非必须
参考示例如下
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();
}
}
}
Metadata
Release files for tisdk 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| tisdk-0.1.2.tar.gz | 10.0 kB | Without provenance | Details |
Release files / tisdk-0.1.2.tar.gz
| Download URL | tisdk-0.1.2.tar.gz |
|---|---|
| Size | 10.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
569bdf11558504b59fab9d83bc4f7e280dba71b8a4375ec27e9eb6b0b0ec218c
|
|
BLAKE2b-256 checksum How to use checksums |
eaff569f1587167facf28f3fa6c7a8fa3a092fae665838e90bba3731e180e8ea
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|
Security for tisdk 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.