Signature 阿里云签名值获取方法
<?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."\n"; $q_str = substr($q_str,0,-1); //echo $q_str."\n"; $StringToSign .= urlencode($q_str); //echo $StringToSign."\n"; $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."\n"; } CreateUploadVideo(); ?>
posted on 2018-10-29 17:43 makeinchina 阅读(1016) 评论(0) 编辑 收藏 举报