29 lines
865 B
PHP
29 lines
865 B
PHP
|
|
<?php
|
||
|
|
|
||
|
|
function sign_message($data) {
|
||
|
|
$timestamp = time();
|
||
|
|
$nonce = mt_rand(100000, 999999); // 生成一个六位随机数
|
||
|
|
$message = "$timestamp|$nonce|" . json_encode($data);
|
||
|
|
$key = 'qZ6v1&H#Wjx+yRm2D@*sJF$tnfL83Ia'; // 签名密钥,请自行设置
|
||
|
|
$signature = hash_hmac('sha256', $message, $key);
|
||
|
|
$signed_message = array(
|
||
|
|
'TaskData' => $data,
|
||
|
|
'signature' => array(
|
||
|
|
'signature' => $signature,
|
||
|
|
'timestamp' => $timestamp,
|
||
|
|
'nonce' => $nonce
|
||
|
|
)
|
||
|
|
);
|
||
|
|
return json_encode($signed_message);
|
||
|
|
}
|
||
|
|
|
||
|
|
$data = array(
|
||
|
|
"command" => "lastCall",
|
||
|
|
"excluded_filename" => "lastCall.txt",
|
||
|
|
"batch_filename" => "Communication_definition_SMS_1_wemedia_20230303185518.txt",
|
||
|
|
"data_filename" => "Communication_targets_SMS_1_wemedia_20230303185518.txt"
|
||
|
|
);
|
||
|
|
|
||
|
|
echo sign_message($data);
|
||
|
|
|