#!/usr/bin/perl -w use HTTP::Tiny; use POSIX qw(strftime); use Encode; use Digest::SHA qw(hmac_sha1); 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 = "345345435"; my $url = "https://sms-intl.ap-southeast-1.aliyuncs.com"; my $data = { AccessKeyId => "Tgfdgdfgdfg", 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 ); printf "params = %s\n", $params; my $encode_message = encode('utf8',$Nonce.$params); my $signature = hmac_sha1 ($encode_message); printf "sig = %s\n",$signature;