in reply to Re^3: signature problem
in thread signature problem

there not much problem, but the major problem is to construct the message and declare signature inside the $data array

#!/usr/bin/perl -w use HTTP::Tiny; use POSIX qw(strftime); use Time::HiRes qw(gettimeofday); use Encode; use Digest::SHA qw(hmac_sha1_base64); my $ua = HTTP::Tiny->new; $timestamp = strftime '%Y-%m-%dT%H:%M:%S', gmtime(); $ip = $ENV{'REMOTE_ADDR'}; $Nonce = int(rand(1000000)); $access_key = "ddizvEmwcLu", $from = "sfsdfdf"; $message = "asdasd"; $to = "5435345435"; my $url = "https://sms-intl.ap-southeast-1.aliyuncs.com"; my $data = { AccessKeyId => $access_key, 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 => $signature, }; print "Content-type: text/html\n\n"; my $params = $ua->www_form_urlencode( $data ); my $signature = hmac_sha1_base64($params, $access_key); my $response = $ua->get( $url . '/?' . $params ); print $response->{'content'} . "\n"; printf "params = %s\n", $params; printf "sig = %s\n",$signature;

Replies are listed 'Best First'.
Re^5: signature problem
by poj (Abbot) on Sep 04, 2019 at 20:31 UTC
    See Step 5
    5. Add the obtained signature value to the request parameters as the Signature parameter to sign the request. 
    
    poj
    A reply falls below the community's threshold of quality. You may see it by logging in.