Skip to content
本页内容

概述

基本要求说明

  • 所有接口调用与返回数据统一 UTF8 编码, JSON 格式
  • HTTP-Header 中的 Date 参数使用 GMT 时间格式
  • 接口调用全部使用 HTTPS
  • 所有 API 参数返回值全部都区分大小写

签名算法

应用文档接口,采用 WPS-2 签名算法计算请求签名。签名内容放在请求头中携带。在线签名检查

说明

标准 sha1 算法结果为一个 40 个字符的字符串,16 进制小写表示的 string。

  • Content-Md5 HTTP Body 中数据的 md5 值十六进制表达方式, 必需小写,如果是 get 请求一律使用 URI 计算 MD5, 例如: uri=/api/files/123?filter=folder
  • Content-Type 固定为: application/json
  • DATE 使用 RFC1123 时间格式的当前时间, 格式: Wed, 23 Jan 2022 06:43:08 GMT
  • Authorization: "WPS-2:" + APPID + ":" + sha1( APPKEY + Content-Md5 + Content-Type + DATE)

代码实例

完整 HTTP 实例

POST /api/v1/openapi/office/convert/to/pdf
Content-Md5: d41d8cd98f00b204e9800998ecf8427e
Content-Type: application/json
DATE: Wed, 23 Jan 2013 06:43:08 GMT
Authorization: WPS-2:SX20220714PWALPQ:ac59dac1460772a04b3a97d7ef78409f28241e3a

{
    "url": "https://xxx.com/xxx",
    "filename": "文字文稿.docx"
}

完整 python 实例

from hashlib import sha1

APPID = "SX20220714PWALPQ"
APPKEY = b"wJalrXUtnFEYEXAMPLEKES"
Content_Md5 = b"d41d8cd98f00b204e9800998ecf8427e"
Content_Type = b"application/json"
Date = b"Wed, 23 Jan 2013 06:43:08 GMT"

signature = sha1(APPKEY+Content_Md5+Content_Type+Date).hexdigest()

print(signature)
# output > 083500176fa3aab58ca2dc962978013b3ca2b6df

Authorization = 'WPS-2:%s:%s' % (APPID, signature)
print(Authorization)
# output > WPS-2:SX20220101ABCDEF:083500176fa3aab58ca2dc962978013b3ca2b6df