<?php

$API_KEY = "4e2bf206a82f846c699e978cea8c2f87";
$API_SECRET = "e763f998cbc9ceb3ff41356638d18e7725cb6b6d2ae02bdc4bdbba55a0978a4f";

$params = [
    "start_date" => "2024-02-02",
    "end_date" => "2026-06-22",
    "page" => "1",
    "limit" => "100",
];

$timestamp = strval(time());

ksort($params);
$paramStr = "";
foreach ($params as $k => $v) {
    if ($v !== null && $v !== "") {
        if ($paramStr) $paramStr .= "&";
        $paramStr .= "{$k}={$v}";
    }
}
$fullStr = "{$paramStr}&timestamp={$timestamp}";

$sign = hash_hmac("sha256", $fullStr, $API_SECRET);

echo "=" . str_repeat("=", 59) . "\n";
echo "Postman 请求配置\n";
echo "=" . str_repeat("=", 59) . "\n";
echo "GET http://localhost:8000/api/v1/chuku?{$paramStr}\n\n";
echo "Headers:\n";
echo "  X-API-Key:   {$API_KEY}\n";
echo "  X-Timestamp: {$timestamp}\n";
echo "  X-Sign:      {$sign}\n\n";
echo "注意: 签名有效期 7 天，过期请重新运行此脚本生成\n";
