Am having a problem with my script

Am getting this error

{"label":"REQUEST_EXPIRED","message":"gap between request Timestamp and server time exceeds 60"} HTTP POST error code: 403 HTTP POST error message: Forbidden

This is the API shell example

key="YOUR_API_KEY" secret="YOUR_API_SECRET" host="https://api.gateio.ws" prefix="/api/v4" method="POST" url="/withdrawals" query_param="" body_param='{"withdraw_order_id":"order_123456","currency":"USDT","add +ress":"1HkxtBAMrA3tP5ENnYY2CZortjZvFDH5Cs","amount":"222.61","memo":" +","chain":"TRX"}' timestamp=$(date +%s) body_hash=$(printf "$body_param" | openssl sha512 | awk '{print $NF}') sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestam +p" sign=$(printf "$sign_string" | openssl sha512 -hmac "$secret" | awk '{ +print $NF}') full_url="$host$prefix$url" curl -X $method $full_url -d "$body_param" -H "Content-Type: applicati +on/json" \ -H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"

This is my code

#!/usr/bin/perl use strict; use warnings; use LWP::UserAgent; use JSON qw( encode_json ) use Digest::SHA qw(hmac_sha512_hex); use MIME::Base64; use POSIX qw( strftime ); my $apiKey = 'demo'; my $host = "https://api.gateio.ws"; my $prefix = "/api/v4"; my $url = '/withdrawals'; my $query_param = ''; my %mas = ( "amount" => "222.61", "currency" => "USDT", "address" => "1HkxtBAMrA3tP5ENnYY2CZortjZvFDH5Cs", "chain" => "TRX" ); my $body = encode_json \%mas; my $time = time; my $timestamp = strftime("%Y%m%d %S", localtime($time)); my $sign_headers = hmac_sha512_hex('POST', $prefix . $url, $query_para +m, $body, $timestamp); my %payload = ( "KEY" => $apiKey, "Timestamp" => $timestamp, "SIGN" => $sign_headers, "Content-Type" => 'application/json' ); my $ua = LWP::UserAgent->new; my $response = $ua->post( $host . $prefix . $url, %payload, Content => $body ); if ($response->is_success) { print $response->decoded_content; } else { print $response->decoded_content; print "HTTP POST error code: ", $response->code, "\n"; print "HTTP POST error message: ", $response->message, "\n"; }

I believe the problem is here

Example indicates

timestamp=$(date +%s)

And me am doing it this way

my $time = time; my $timestamp = strftime("%Y%m%d %S", localtime($time)); # prints example 20240924 55

In reply to REQUEST EXPIRED by frank1

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.