1. 程式人生 > >Signature 阿裏雲簽名值獲取方法

Signature 阿裏雲簽名值獲取方法

demo tle access http -s ces true shanghai c-s

<?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();

?>  

  

Signature 阿裏雲簽名值獲取方法