regarding my question (alibaba cloud sms api)

i got the direct code in my cloud account, and wen i put it directly in browser. it works well and delivers my sent sms

https://sms-intl.ap-southeast-1.aliyuncs.com/?AccessKeyId=dsfsdfdsfdsf +dsf&Action=SendMessageToGlobe&Format=JSON&From=sdsadf&Message=gthet&R +egionId=default&SecureTransport=true&SignatureMethod=HMAC-SHA1&Signat +ureNonce=0c4766c8889267ca02d733342a973461&SignatureVersion=1.0&Source +Ip=41.210.145.133&Timestamp=2019-09-04T11%3A54%3A52Z&To=345435435435& +Version=2018-05-01&Signature=j7UIvC%2B9whf1KyLxTjv0K4aFCyc%3

so i constructed this in perl like this, seems working well

#!/usr/bin/perl -w use HTTP::Tiny; use POSIX qw(strftime); my $ua = HTTP::Tiny->new; $timestamp = strftime '%Y-%m-%dT%H:%M:%S', gmtime(); $ip = $ENV{'REMOTE_ADDR'}; $Nonce = int(rand(1000000)); $from = "sfsdfdf"; $message = "asdasd"; $to = "434534543"; my $url = "https://sms-intl.ap-southeast-1.aliyuncs.com"; my $data = { AccessKeyId => "sdsadasdasd", Action => "SendMessageToGlobe", Format => "JSON", From => $from, Message => $message, RegionId => "default", SecureTransport => "true", SignatureMethod => "HMAC-SHA1", SignatureNonce => $Nonce, SignatureVersion => "1.0", SourceIp => $ip, Timestamp => $timestamp, To => $to, Version => "2018-05-01", Signature => "j7UIvC+9whf1KyLxTjv0K4aFCyc=", }; my $params = $ua->www_form_urlencode( $data ); my $response = $ua->post( $url . '/?' . $params ); print "Content-type: text/html\n\n"; print $response->{content} . "\n";

now my problem is this. when i run i get the follow error

{"Recommend":"https://error-center.aliyun.com/status/search?Keyword=Si +gnatureDoesNotMatch&source=PopGw","Message":"Specified signature is n +ot matched with our calculation. server string to sign is:POST&%2F&Ac +cessKeyId%sdsadasd%26Action%3DSendMessageToGlobe%26Format%3DJSON%26Fr +om%3Dsfsdfdf%26Message%3Dasdasd%26RegionId%3Ddefault%26SecureTranspor +t%3Dtrue%26SignatureMethod%3DHMAC-SHA1%26SignatureNonce%3D659993%26Si +gnatureVersion%3D1.0%26SourceIp%3D41.210.145.133%26Timestamp%3D2019-0 +9-04T13%253A49%253A02%26To%3D534534543345%26Version%3D2018-05-01","Re +questId":"0C5E81D6-69E6-45FE-85AA-9D89E5C23267","HostId":"sms-intl.ap +-southeast-1.aliyuncs.com","Code":"SignatureDoesNotMatch"}

sometimes i get Signature was already used

so my question is, does signature have to be random generated. coz thats the only error am facing only

coz when i run there direct code in through there system, it works well and wen i check debug report. in cloud account. i see signature changed


In reply to signature problem by bigup401

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.