<?php function CreateUploadVideo(){ $a='LT*****Q8'; $ck='hEro****vqPbj'; $h_8_time = time() - 8*60*60; $get_key = array('Format','Version','AccessKeyId','SignatureMethod','Timestamp','SignatureNonce','SignatureVersion','Action','Title','FileName'); $get_key_value = array('Format' => 'JSON','Version' => '2017-03-21','SignatureMethod' => 'HMAC-SHA1','SignatureNonce' => time() + rand(50000,100000),'SignatureVersion' => '1.0','AccessKeyId' => $a,'Timestamp' => date('Y-m-d',$h_8_time).'T'.date('H:i:s',$h_8_time).'Z','Action' => 'CreateUploadVideo','Title' => 'PHP_Demo_signature','FileName'=>'config.mp4'); sort($get_key); $StringToSign = 'GET&'.urlencode('/').'&'; $q_str = ''; foreach($get_key as $kval){ $q_str .= urlencode($kval).'='.urlencode($get_key_value[$kval]).'&'; } //echo $q_str." "; $q_str = substr($q_str,0,-1); //echo $q_str." "; $StringToSign .= urlencode($q_str); //echo $StringToSign." "; $ok_url = 'http://vod.cn-shanghai.aliyuncs.com?'.$q_str.'&Signature='.urlencode(base64_encode(hash_hmac("sha1",$StringToSign,$ck.'&',true))); //sha1($StringToSign,true) echo $ok_url." "; } CreateUploadVideo(); ?>