融合消息平台(MSMC UNIM)对接
快速开始
1. 获取Token
from msmc_client import MSMCClient
client = MSMCClient(
base_url='https://unim.i139.cn:6443/messaging',
account='${ACCOUNT}',
password='${PASSWORD}'
)
client.get_token()
2. 发送5G消息(必须参数)
message_id = str(uuid.uuid4())
contribution_id = str(uuid.uuid4())
conversation_id = str(uuid.uuid4())
client.send_5g_message(
template_id='${TEMPLATE_ID}',
mobile='${MOBILE}',
message_id=message_id,
contribution_id=contribution_id,
conversation_id=conversation_id
)
SDK使用
详见 scripts/msmc_client.py,包含完整实现:
get_token()- 获取访问令牌send_5g_message()- 发送5G消息
认证机制
Token获取
POST /api/user/token
Body: {"auth": "<base64>", "timestamp": <long>, "sign": "<base64>"}
auth生成规则:
1. 密码SHA256 → Hex
2. 拼接 timestamp → SHA256 → Hex
3. 账号# + 步骤2结果 → Base64
请求签名
所有接口需要对参数进行签名:
1. 参数按key字典序排序
2. 拼接 key1=value1&key2=value2
3. SHA256 → Hex → Base64
API参考
详见 references/api_reference.md