Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^4: signature problem

by bigup401 (Pilgrim)
on Sep 04, 2019 at 19:45 UTC ( [id://11105624]=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11105624]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (5)
As of 2024-04-19 12:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found