求救各位大佬,我用python调用wps的pdf转word接口,但是爆{"code":30003,"message":"InvalidSignature","hint":"not a valid datetime or too skewed. Date: Thu, 23 Oct 2025 15:08:42 GMT","extra":""}这个错误。请问问题出在哪了 具体代码如下:
import http.client
import hashlib
import datetime
import os
conn = http.client.HTTPSConnection("solution.wps.cn")
# 使用实际的PDF URL
payload = "{\"url\":\"https://www.learningcontainer.com/wp-content/uploads/2019/09/sample-pdf-file.pdf\"}"
# 生成当前时间(实际使用时应该用当前时间)
current_date = datetime.datetime.now().strftime("%a, %d %b %Y %H:%M:%S GMT")
# 计算实际的Content-MD5(请求体的MD5值)
content_md5 = hashlib.md5(payload.encode('utf-8')).hexdigest()
headers = {
'Date': current_date,
'Content-Md5': content_md5,
'Content-Type': "application/json",
'Authorization': "WPS-2:*****:*******************"
}
conn.request("POST", "/api/developer/v1/office/pdf/convert/to/docx", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))