跳到主要内容

开发调用电子签接口

一. 腾讯云 SDK

推荐使用腾讯云 SDK 进行接口调用。腾讯云 SDK 可以帮助开发者快速调用到指定的云 API 的接口,并且解决客户端签名的问题。

以下是各种语言的 SDK 介绍,开发者可根据自己的语言,安装对应的 SDK。

二.代码调用

DescribeTemplates接口为例,调用代码如下。

Java
Python
PHP
Go
nodejs
.Net

import com.tencentcloudapi.common.Credential;
import com.tencentcloudapi.common.profile.ClientProfile;
import com.tencentcloudapi.common.profile.HttpProfile;
import com.tencentcloudapi.common.exception.TencentCloudSDKException;
import com.tencentcloudapi.essbasic.v20210526.EssbasicClient;
import com.tencentcloudapi.essbasic.v20210526.models.*;

public class DescribeTemplates
{
public static void main(String [] args) {
try{
// 实例化一个认证对象,入参需要传入腾讯云账户 SecretId 和 SecretKey,此处还需注意密钥对的保密
// 代码泄露可能会导致 SecretId 和 SecretKey 泄露,并威胁账号下所有资源的安全性。以下代码示例仅供参考,建议采用更安全的方式来使用密钥,请参见:https://cloud.tencent.com/document/product/1278/85305
// 密钥可前往官网控制台 https://console.cloud.tencent.com/cam/capi 进行获取
Credential cred = new Credential("SecretId", "SecretKey");
// 实例化一个http选项,可选的,没有特殊需求可以跳过
HttpProfile httpProfile = new HttpProfile();
httpProfile.setEndpoint("essbasic.tencentcloudapi.com");
// 实例化一个client选项,可选的,没有特殊需求可以跳过
ClientProfile clientProfile = new ClientProfile();
clientProfile.setHttpProfile(httpProfile);
// 实例化要请求产品的client对象,clientProfile是可选的
EssbasicClient client = new EssbasicClient(cred, "", clientProfile);
// 实例化一个请求对象,每个接口都会对应一个request对象
DescribeTemplatesRequest req = new DescribeTemplatesRequest();

// 返回的resp是一个DescribeTemplatesResponse的实例,与请求对象对应
DescribeTemplatesResponse resp = client.DescribeTemplates(req);
// 输出json格式的字符串回包
System.out.println(DescribeTemplatesResponse.toJsonString(resp));
} catch (TencentCloudSDKException e) {
System.out.println(e.toString());
}
}
}

三.使用腾讯云 API Explorer

腾讯云 API Explorer 工具 是一款自动化工具,可以支持腾讯电子签的集成 API 接口调用自动化。可实现自动生成 Java、Python、Node.js、PHP、GO 及 .NET 语言的 SDK 代码、在线调用、发送真实请求及签名串自动生成等功能,降低了 SDK 的使用难度。

您可通过 API Inspector 查看控制台每一步操作关联的 API 调用情况,并自动生成各语言版本的 API 代码,也可前往 API Explorer 进行在线调试。

调用测试环境接口

参考下图所示,选择 ESSBASIC,点击更多选项,输入测试环境 SecretId 与 SecretKey,输入测试环境域名,即可调用测试环境接口。

四. Postman

您还可以选择Postman作为接口调试方案。我们已经准备好了测试集,您只需要简单修改几个环境变量,即可发起相关API的调用。

具体使用方式请参考Postman工具

需要按照Postman工具对应的仓库方式导入,因为这样导出的测试集合才会包含 Postman 的前置脚本。如果不按照操作进行或自己添加,那么发起的请求可能会报错,因为缺少 Postman 的前置脚本。

购买咨询
4006-808-062
4006-808-062