update20260427
This commit is contained in:
42
OTHERS/external_triggered_email.py
Normal file
42
OTHERS/external_triggered_email.py
Normal file
@@ -0,0 +1,42 @@
|
||||
# Databricks notebook source
|
||||
import base64
|
||||
import time
|
||||
import urllib.parse
|
||||
import requests
|
||||
from Crypto.Cipher import AES
|
||||
from Crypto.Util.Padding import pad
|
||||
|
||||
# === 配置区 ===
|
||||
# Spring Boot 服务端的密钥(Base64编码)
|
||||
SECRET_KEY_BASE64 = "qkLkLHPnqNfJ5d3X6DgLpw=="
|
||||
# 接口地址
|
||||
# https://mdcuat.astrazeneca.cn/earth/app/mail/task/ma/check
|
||||
# https://mdc.astrazeneca.cn/earth/app/mail/task/ma/check
|
||||
API_URL = "https://mdc.astrazeneca.cn/earth/app/mail/task/ma/check"
|
||||
|
||||
# === AES 加密函数 ===
|
||||
def generate_aes_token(secret_key_base64: str) -> str:
|
||||
# Hutool 的 SecureUtil.aes() 默认是 AES/ECB/PKCS5Padding
|
||||
secret_key = base64.b64decode(secret_key_base64)
|
||||
cipher = AES.new(secret_key, AES.MODE_ECB)
|
||||
|
||||
# 加密当前时间戳(毫秒)
|
||||
timestamp = str(int(time.time() * 1000))
|
||||
encrypted = cipher.encrypt(pad(timestamp.encode("utf-8"), AES.block_size))
|
||||
|
||||
# 输出 Base64 编码的 token
|
||||
return base64.b64encode(encrypted).decode("utf-8")
|
||||
|
||||
# === 调用接口 ===
|
||||
def call_check_api():
|
||||
token = generate_aes_token(SECRET_KEY_BASE64)
|
||||
encoded_token = urllib.parse.quote(token)
|
||||
url = f"{API_URL}?token={encoded_token}"
|
||||
|
||||
print(f"请求URL: {url}")
|
||||
response = requests.get(url)
|
||||
print("响应状态码:", response.status_code)
|
||||
print("响应内容:", response.text)
|
||||
|
||||
if __name__ == "__main__":
|
||||
call_check_api()
|
||||
Reference in New Issue
Block a user