'commit'
This commit is contained in:
@@ -17,7 +17,7 @@ class JmCommon:
|
||||
schema = "https"
|
||||
version = "2022-08-31"
|
||||
|
||||
# API访问凭证
|
||||
# API访问凭证 - 请替换为您自己的凭证
|
||||
ak = "AKLTZjVlOGU1NzA1YWZkNDExMzkzYzY5YTNlOTRmMTMxODg"
|
||||
sk = "WkdabU9UTXdNVEJpTmpWbE5HVTJZVGxtTnpWbU5XSTBaRGN5TW1NMk5tRQ=="
|
||||
|
||||
@@ -68,12 +68,16 @@ class JmCommon:
|
||||
@staticmethod
|
||||
def gen_signing_secret_key_v4(date, region, service):
|
||||
"""生成V4版本的签名密钥"""
|
||||
# 注意:这里sk需要解码,因为Java代码中sk是Base64编码的
|
||||
sk_bytes = base64.b64decode(JmCommon.sk)
|
||||
k_date = JmCommon.hmac_sha256(sk_bytes, date)
|
||||
k_region = JmCommon.hmac_sha256(k_date, region)
|
||||
k_service = JmCommon.hmac_sha256(k_region, service)
|
||||
return JmCommon.hmac_sha256(k_service, "request")
|
||||
try:
|
||||
# 解码SK (Base64)
|
||||
sk_bytes = base64.b64decode(JmCommon.sk)
|
||||
k_date = JmCommon.hmac_sha256(sk_bytes, date)
|
||||
k_region = JmCommon.hmac_sha256(k_date, region)
|
||||
k_service = JmCommon.hmac_sha256(k_region, service)
|
||||
k_signing = JmCommon.hmac_sha256(k_service, "request")
|
||||
return k_signing
|
||||
except Exception as e:
|
||||
raise Exception(f"生成签名密钥失败: {str(e)}")
|
||||
|
||||
@staticmethod
|
||||
def do_request(method, query_list, body, action):
|
||||
@@ -139,6 +143,8 @@ class JmCommon:
|
||||
|
||||
# 发送请求
|
||||
try:
|
||||
print(f"请求URL: {url}")
|
||||
print(f"请求头: {headers}")
|
||||
response = requests.request(
|
||||
method=method,
|
||||
url=url,
|
||||
@@ -146,6 +152,8 @@ class JmCommon:
|
||||
data=body,
|
||||
timeout=(30, 30) # 连接超时和读取超时
|
||||
)
|
||||
print(f"响应状态码: {response.status_code}")
|
||||
print(f"响应内容: {response.text}")
|
||||
response.raise_for_status() # 如果状态码不是200,抛出异常
|
||||
return response.text
|
||||
except requests.exceptions.RequestException as e:
|
||||
|
Binary file not shown.
Reference in New Issue
Block a user